I have a large number of files in various folders and subfolders that I need to batch process through a tool that doesn't retain paths. /this/that/and/this.ext winds up as /this.ext. I want to preserve the folder structure, so I thought I'd use KM to...
Rename the files to include the path in their filenames.
Move the renamed files to an inbox for the batch tool.
Execute the batch tool (manually or by triggering with KM or Hazel when files are in the inbox)
Take the output from the tool and parse their file names back into paths.
The problem? I have no idea how to do any of this. Please help?
Here's the path to a single example file.
/Volumes/Media Drive/Comic Books/__IN To Be Compressed/Marvel Noir/Iron Man Noir/Iron Man Noir 04 (of 04) (2010).cbr
I want to be able to send that through the batch compression tool and then get it back to that full path again. It seems to me the best way to do that is with the above process, but I don't know how to build the macros in KM to make that work.
How could I get KM to return each file to its original location? Keep in mind those original locations will be different.
Also, I'm sending this through a Windows program, which strips out MacOS Tags and Comments, so I can't use those (I tried). Thus my thought that I'd need to put the path into the file name, then parse the file name back into paths... Though I have no idea how to tell KM to do that.
Well, presumably you have to find the file in the first place somehow. Either with the Folder Contents collection, or maybe using find via the Execute a Shell Script. That gives you the path you are going to rename/move from and then rename/move back to.
How do I do that, Peter? How do I add each folder in the path to the filename, then, after processing, take those path parts and turn them back into an actual path to which to move the file? Those two points are where I'm asking for help. The rest I can manage on my own.
Note that files are spread across numerous paths with different folder/subfolder depths.
I'd LIKE to just point KM to a particular folder--maybe one I set via a variable--and have it do the renaming (during a copy or move to an inbox folder for the app). If that's not easy, I can select the files in Finder and do a For Each > Path on the Finder Selection. What I DO in that For Each is where I'm confused.
This will process all (recursively) the files that end with .txt in the folder ~/MyFolder/DoStuff.
Each file in that folder will be moved to the ~/Processing folder and named thefile.txt
You can then process the file as necessary with a fixed name and location.
Then the file will be moved and renamed back to its original location and name.
Clearly this is a rather invasive procedure, so you should be careful and know what you are doing. If the folder contains files you don't expect, they will be processed too. If you point it at the wrong folder, then you could do a lot of damage. So don't even start with things like that until you are confident in your backup system.