By Vanessa Garde @Vanessa_Garde
Hi there,
I'd love to be able to have a shortcut in finder to:
- Move selected files to an "_OLD" folder, if existing on the same location.
- If not, create an "_OLD" folder (without the quotes) and them move the selected files to that location.
Any hints, please? :-)
Thanks a lot!!!
Vanessa G.
Linked from:
- Christian Scheuer @chrscheuer2021-02-01 11:10:03.618Z
This should do it :)
function moveFiles({ sourcePaths, targetFolder }) { for(let sourcePath of sourcePaths) { var sourceFilename = sourcePath.split('/').slice(-1)[0]; var targetPath = targetFolder + '/' + sourceFilename; sf.file.move({ sourcePath: sourcePath, destinationPath: targetPath, }); } } function main() { var sourcePaths = Array.from(sf.ui.finder.selectedPaths); if (sourcePaths.length === 0) return; var sourceFolder = sourcePaths[0].split('/').slice(0, -1).join('/'); var targetFolder = `${sourceFolder}/_OLD`; sf.file.directoryCreate({ path: targetFolder }); moveFiles({ sourcePaths, targetFolder, }); } main();
- VVanessa Garde @Vanessa_Garde
Wow! That worked!!! Thank you so much!!!! :-)
- In reply tochrscheuer⬆:RRob Byers @Rob_Byers
This is a part of my workflow as well, and just came on the forum on a whim to see if I could use SoundFlow to automate it. First result brings me to this question and code. THANK YOU both! Putting it to work immediately!