Copy link to clipboard
Copied
Three questions
1. I'm trying to parse out and move files from a source directory into a shot's folder structure.
_plate into elements
.cdl into lut
_plate.mov into elements
_QT_REF_ into ref
.cube into lut
I've figured out how test if the file name contains the relevant data. (This only looks at specific files currently)
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
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.
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.
Onwards to my last step of incorporating the copy folder function you wrote to move a folder and it's content.
As always, thank you for your input and feedback.
Copy link to clipboard
Copied
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).
Copy link to clipboard
Copied
re: #3 - It's the last block in the stack and as you've mentioned before on another thread there is no feedback.
So I've been running the .bat by hand when the script is done. Not "optimal", but it is "functional".
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more