I have a lot of JPGs on the /tmp directory that i have printed from the web using Kunvert.app via “PDF Services” but every time i print one it is saved on a new folder named “printing(dot sumtin)” and the files are been saved as “Print job.jpg” now, i have to take those files out so i have made a contextual menu using “on my command” to move the files from /tmp to my desktop but then all files are overwritten by the last one and i end with just one file…
#On my command script (Move JPGs) ############### mv /tmp/printing*/* /Users/myhomedirectory/Desktop/ ##############
I’m interested on doing a script to move and rename those files sequentially to my Desktop or any other directory. I have tried to make an applescript but then the script is unable to see the /tmp directory.
I had the same problem months ago when a client gave me a CD with lots of folders with some files inside but all the files was named the same way no matter in which folder they were stored… the procedure then was to use “R-name.app” to rename those files from something.pdf to something ‘00+1’.pdf that doesn’t bothered me since i just have to drop the folders from CD to app but now i have to:
Print to JPG
- go to /tmp
- select folders
- drop to R-name.app
- run contextual menu script in order to move all files to a directory
By now I’m not even halfway doing this job and I still have a lot of files to print this way so I have made other script but I’m sure it can be improved someway since it opens Kunvert.app and R-Name.app to do the job…
#Move&Rename after Printing #All PDFs have been converted to JPGs during the print process via Kunvert and PDF Services #This script will make a new dir on the Desktop then it will open R-Name in order to add a prefix/suffix to rename files sequentially and pauses the process till R-Name is closed then the process will go ahead and will move all file to the newly created folder once the files are there, all the dirs in /tmp named "printing" will be deleted #!/bin/sh cd ; mkdir /Users/MyHomeDir/Desktop/imgs ; cd /Users/MyHomeDir/Desktop/imgs open -a R-Name /tmp/printing*/* mv /tmp/printing*/* /Users/MyHomeDir/Desktop/imgs/ rm -R /tmp/printing*
I have found on this forums a way to rename files in a single process but I still have two problems 1) the script can’t see files inside subfolders 2) it seems that the script needs root privileges to browse the /tmp directory. The only way for me to get to that directory using applescript is by an alias of /tmp placed in a more accessible path, then again it can’t browse subfolders
BTW I’ve chaged somethings to the original scrip made by… (damn i forgot your name and i don’t remember how i get to that thread… thx a lot anyway) like the prefix line and now the script will rename only JPEG files.
property the_prefix : "0" tell application "Finder" open file "tmp" in folder "X" in folder "XXX" in disk "XXX" -- this is the alias of /tmp end tell try tell application "Finder" to set the source_folder to (folder of the front window) as alias on error -- no open folder windows set the source_folder to path to desktop folder as alias end try tell application "Finder" -- get the current folder listing set sourceFiles to every file of source_folder whose name contains ".jpg" -- start off with file 1 set fileCounter to 1 --loop through the files repeat with aFile in sourceFiles --renaming each one in turn set name of aFile to (the_prefix & fileCounter & ".jpg") as string -- and incrementing the counter after each file set fileCounter to fileCounter + 1 end repeat end tell
The last part of this script will be:
do shell script "#!/bin/sh ; mv /tmp/printing*/* /Users/MyHomeDir/Desktop/imgs/ ; rm -R /tmp/printing*"
to move the renamed files the desktop and then delete all folders named “printing” on the /tmp directory.
What do you think is it possible to do what I’m trying to do?