PDA

View Full Version : need help with script




Marsheezi
Jun 28, 2007, 05:02 PM
okay i've been looking around and i think its possible, but not sure. hopefully somebody can help me out.

let say i have about 5000 files. all with the name scheme:

10482 Something.jpg
49230 Whatever.jpg
12301 Pleasehelpme.jpg

is there a script that can take the numbers that exist in the first part of the filename and remove the remaining characters from the filename?

ex.
10482 Something.jpg ----> 10482.jpg
49230 Whatever.jpg -----> 49230.jpg
12301 Pleasehelpme.jpg ------> 12301.jpg

the numbers aren't sequential so none of the renaming tools i found can help, and the number of characters after the numbers isnt contant so just chopping off several characters before the file extension wont help.

anythoughts???
thanks in advance



MongoTheGeek
Jun 28, 2007, 06:05 PM
okay i've been looking around and i think its possible, but not sure. hopefully somebody can help me out.

let say i have about 5000 files. all with the name scheme:

10482 Something.jpg
49230 Whatever.jpg
12301 Pleasehelpme.jpg

is there a script that can take the numbers that exist in the first part of the filename and remove the remaining characters from the filename?

ex.
10482 Something.jpg ----> 10482.jpg
49230 Whatever.jpg -----> 49230.jpg
12301 Pleasehelpme.jpg ------> 12301.jpg

the numbers aren't sequential so none of the renaming tools i found can help, and the number of characters after the numbers isnt contant so just chopping off several characters before the file extension wont help.

anythoughts???
thanks in advance

tell application "Finder"
set aList to every file of folder (choose folder)
repeat with anItem in aList
set aName to name of anItem
set aName to word 1 of aName&".jpg"
set name of anItem to aName
end
end

/money for nuttin'
//Scripts for free