Q: Script to move and rename files with sequential number based on filename
Pls help. I need a script to move and rename files based on filename. New name should have sequential index number.
I have three different folders "PPM", "MM6", "MM9" and they have their own different index numbers.
i.e :
ppm-01.jpg to /PPM folder and rename to PPM4876.jpg (4876 is next sequential number in PPM folder)
mm9-01.jpg to /MM9 folder and rename to MM9396.jpg (396 is next sequential number in MM9 folder)
mm6-01.jpg to /MM6 folder and renamed to MM6325.jpg (325 is next sequential number in MM6 folder)
I have a script that I run as app. It works only for one "PPM" files and I can't figure out how to make it work
for the other two groups ("MM6", "MM9")
property theName : "PPM" -- the baseName
property n : 4876 -- the starting number
property theExt : ".jpg" -- name extension
global watchFolder, destinationFolder
on run
set watchFolder to "Media HD:DBASE:Files:CONTAINERS:DROP:UNFILTERED:" as text
set destinationFolder to "Media HD:DBASE:Files:CONTAINERS:DROP:PPM:" as text
end run
on idle
repeat
tell application "System Events"
repeat with i in (get files of folder watchFolder whose name ends with theExt)
move i to destinationFolder
set name of the result to theName & n & theExt
set n to n + 1
end repeat
end tell
delay 1
end repeat
end idle
Please help.
iMac (27-inch, Late 2012), iOS 9.3.3, null
Posted on Aug 3, 2016 1:35 PM