Move and Rename sequentially

BoneFill

Registered
HELP PLS!!! :(

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 so 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 not to mention that i have no idea bout how can i add a sequential prefix/suffix :p so i guess it will end the same way... with just a single file instead of all my files...

I had the same problem months ago when a client gives 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
Any ideas on how can i make this whole process by running a single script from "PDF Services" or by running a script after files are printed?

TIA
 
I've found something that could help doing this Move & Rename process but to be honest I have no idea 'bout how to use it... if someone could take a look at it and tell me what am I supposed to do with this file CMV (Batch Rename)

The only thing I know about this file by now is that it uses Perl to make the process...

I have one more question, how is that the system makes a copy named file copy.whatever from a file named file.whatever and from that point the system will rename every new copy as file copy 1|2|3.whatever? this behavior can be reproduced someway don't it?
 
About your last question: Would you rather it do like OS 9 does, and add "copy" after the extension? I think this has something to do with the fact that it's UNIX, and each file has a certain name, plus the kind of file it is, and the extension has to do with the kind of file it is and not the name. Or it's just smarter.
 
arden: i don't think a file check for kind/date/extension/size is needed since there are several ways to keep all that data untouched, I'm only interested on renaming files with a suffix+1 for each file so "file copy.ext - file copy 1.ext" or "file.ext copy - file.ext copy 1" so yes i'll use the MacOS 9 way... tell me you know how to do it? :D

Finally i figured out how to use that "cmv" file i just needed to make it executable (chmod 775) and it works fine if you have all your files in one directory but it can't rename files sequentially if the files are on different dirs...

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 two scripts but I'm sure both can be improved someway since both opens Kunvert.app and R-Name.app to do the job, one works during the print process and the other one works after printing
  • #Move&Rename While Printing
    #This will make a new dir on the Desktop convert PDFs to JPGs automatically 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 Kunvert /tmp/printing*/*
    cd /Applications/R-Name.app/Contents/MacOS/ ; ./R-Name /tmp/printing*/*
    mv /tmp/printing*/* /Users/MyHomeDir/Desktop/imgs/
    rm -R /tmp/printing*
  • #Move&Rename after Printing
    #All PDFs have been converted to JPGs during the print process via Kunvert and PDF Services
    #This 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
    cd /Applications/R-Name.app/Contents/MacOS/ ; ./R-Name /tmp/printing*/*
    mv /tmp/printing*/* /Users/MyHomeDir/Desktop/imgs/
    rm -R /tmp/printing*

I'm using the second script cause in the firs one i had to change the prefix/suffix for each printed file and the whole process slows down cause R-Name is launched for every file...
 
For those interested, here's an applescript to do the job:
Code:
[SIZE=2]property MySuffixe : " add " 
  
 on run 
 _ _my SubRename(choose folder) 
 end run 
  
 on SubRename(MyFolder) 
 _ _tell application "Finder" 
 _ __ _activate 
 _ __ _set MyList to every item of MyFolder 
 _ __ _repeat with Loop from 1 to (count every item in MyList) 
 _ __ __ _set MyItem to (item Loop of MyList) as alias 
 _ __ __ _set MyType to get the name of every item of MyItem 
 _ __ __ _set FolderName to get the name of MyFolder 
 _ __ __ _if (the name of MyItem contains "folder") then 
 _ __ __ __ _my SubRename(MyItem) 
 _ __ __ _else if (the name of MyItem contains "jpg") then 
 _ __ __ __ _set name of MyItem to (FolderName & MySuffixe & Loop & ".jpg") 
 _ __ __ _end if 
 _ __ _end repeat 
 _ _end tell 
 end SubRename[/SIZE]

the move part is easy that's why it is not included on this script... now I'm happy :D

Thx to Fredo d;o) at MacScripter BBS
 
Back
Top