Who can help me?
I want to rename the numbers of an ‘splited’ PDF:
I splint an PDF of 120-pages in 120 single-page PDFs
The splitter names the filse like this:
filename_P1.pdf
filename_P2.pdf
filename_P3.pdf
…
filename_P12.pdf
…
filename_P120.pdf
Now I want to rename thise files like:
filename_P001.pdf
…
filename_P012.pdf
…
Filename_P120.pdf (here is no renaming)
Can somone help me.
I am not an script-writer (I only like to use theme)
I dont know how an droplet works, dut it sonds like I can use an script like that to?.
Well there is prolly a more sophisticated way of doing this, but this does work. Please pay special attention to the comment in the script.
on open fileList
tell application "Finder"
repeat with aFile in fileList
set n to name of aFile
-- This next line assumes all files begin with 10 characters followed by the number and then a 3 digit extension
-- These values may need to be changed depending on file name(s)
set {fName, fNUmber, fExt} to {text 1 thru 10, text 11 thru -5, text -4 thru -1} of n
if fNUmber's length is 1 then
set name of aFile to fName & "00" & fNUmber & fExt
else if fNUmber's length is 2 then
set name of aFile to fName & "0" & fNUmber & fExt
end if
end repeat
end tell
end open
this version of James’ script is independent from the length of the file name
but it assumes the “P” is just before the numbering
on open fileList
repeat with aFile in fileList
set {Nm, Ex} to {name, name extension} of (info for aFile)
if Ex is missing value then set Ex to ""
if Ex is not "" then
set Nm to text 1 thru ((count Nm) - (count Ex) - 1) of Nm
set Ex to "." & Ex
end if
set o to offset of "P" in Nm
set {fName, fNUmber} to {text 1 thru o, text (o + 1) thru -1} of Nm
tell application "Finder" to set name of aFile to (fName & (text -3 thru -1 of ("00" & fNUmber)) & Ex)
end repeat
end open
Thanks for the reply’s.
But, what Iam looking for is somthing like this:
(Is an [Folder action script] withs I can usage to zip a lot of files.)
(After zipping the zipped fils are but in an ‘done-folder’)
(So after renaming the files can move to an ‘done-folder’)
on adding folder items to this_folder after receiving these_items
tell application "Finder"
if not (exists folder "Done" of this_folder) then
make new folder at this_folder with properties {name:"Done"}
end if
set the destination_folder to folder "Done" of this_folder as alias
set the destination_directory to POSIX path of the destination_folder
end tell
repeat with i from 1 to number of items in these_items
set this_item to item i of these_items
set the item_info to info for this_item
if this_item is not the destination_folder and the name extension of ¬
the item_info is not in {"zip", "sit"} then
set the item_path to the quoted form of the POSIX path of this_item
set the destination_path to the quoted form of ¬
(destination_directory & (name of the item_info) & ".zip")
do shell script ("/usr/bin/ditto -c -k -rsrc --keepParent " & ¬
item_path & " " & destination_path)
end if
end repeat
end adding folder items to