Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Automation Blocks - Search files/folders in a folder

Contributor ,
Dec 04, 2022 Dec 04, 2022

Three questions

1. I'm trying to parse out and move files from a source directory into a shot's folder structure.

Source Directory.png

_plate into elements

.cdl into lut

_plate.mov into elements

_QT_REF_ into ref

.cube into lut

Destination Directory.png

 

I've figured out how test if the file name contains the relevant data. (This only looks at specific files currently)

Search for Specific Names2.png

What I am unable to figure out is how to search a directory to see if files or folders have the correct conditions so I can move them.

 

2. In working with the Copy files block, I'm noting that it is VERY slow compared to dragging in the finder/explorer window. Any ideas why?

3. Is there a way to move files as opposed to copying them and deleting them?

TOPICS
Scripting
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 04, 2022 Dec 04, 2022

1, you need to use the List of Files block to get a list of all files in the folder and then use the For Each loop, to loop over all files in that list.

2./3. Moving files (in particular big files) is much faster than copying them. Scripting has only features to copy files and not to move them, unfortunately (which would in deed be much faster). I think the scripting engine does not have such a function, hence, it is not just a limitation of AB, but of Ae's scripting engine in general.

Only workaround that comes to my mind for fast moving of files:

step 1. use the Write Text File block to write a .bat file (or on Mac maybe a .sh shell script file) and insert the copy commands you want to execute into that bat file.

step 2. execute the bat file.

That way, copying or moving files will be as fast as doing it in the terminal.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 04, 2022 Dec 04, 2022

So fast on the response! Thank you.

 

Now I have a whole lot of work to do. This is fantastic. I'll share back what I end up with.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 04, 2022 Dec 04, 2022

So this was SUPER helpful in working thru what I've done so far. A couple of questions came up.

1. Can files on the desktop be created via script? I just want to create the .bat file, but I either have to copy on from someplace else, or reuse the same one over and over.

SetBatFile.png

2. Is there a way to set up an array inside the script (rather than using a spreadsheet) to go thru a list of file types or search functions?

.cdl -> lut

.cube -> lut

_QT_REF_ -> ref

_plate.mov -> elements

It just seems like I could economize the if statements here as my file types increases in the future.

ForEachLoop.png

3. Nothing seems to happen when trying to execute the .bat file. When launching it from the desktop it does it's thing, but not from the script. This is what provoked question 1. If I can create a blank .bat file without copying from a blank, it's just one less step.

Execute File.png

Onwards to my last step of incorporating the copy folder function you wrote to move a folder and it's content.

https://community.adobe.com/t5/after-effects-discussions/automation-blocks-copy-folder-and-contents/...

 

As always, thank you for your input and feedback.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 05, 2022 Dec 05, 2022

1. the Write Text File block creates a new file if it does not exist, yet. So yes, you can create a new file on your desktop, if your user has write permissions to do that (which should absolutely be the case for your desktop). If the file already exists, Write Text File will append to the existing file. Hence, to create a new file, you first need to delete the existing one if it already exists.

 

2.Automation Blocks supports lists (arrays), but the datastructure you look for is an object or hash (you want to map a key like ".cdt" to a value like "lut").  The only way to simulate that would be by using two lists of same length:

- one with the keys [".cdt",".cube","_QT_ref_","plate.move"]
- one with the values ["lut", "lut", "ref", "elements"]
Then you could count with some variable i from 1 to the end of the list, search for keys[i] and if keys[i] was found, set "type file" to values[i].
But if you only have four entries in your list, your solution is probably easier to read and it is not worth the effort to change it.

3. That's strange. Does Automation Blocks show any error message or anything helpful in the console? Do you have any antivirus which might block the execution? In general, executing the file with AB should do the same that happens when double-clicking the file in Windows Explorer (i.e. executing the default thing configured for that file type on your system).

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 06, 2022 Dec 06, 2022
LATEST

re: #3 - It's the last block in the stack and as you've mentioned before on another thread there is no feedback.ExecuteFile.png

So I've been running the .bat by hand when the script is done. Not "optimal", but it is "functional".

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines