|
|
better leading zeros code
eliminate the tedious if then(/else;-)s:
better leading zeros code
Please don't assume we all know where to put the code you suggest! Could you specifiy what it replaces? Also the author mentions potential adjustments. What is he meaning?
sorry, i assumed u would RTFC;-)
replace this:
set prefixName to "" if i < 1000 then set prefixName to "0" & prefixName end if if i < 100 then set prefixName to "0" & prefixName end if if i < 10 then set prefixName to "0" & prefixName end if set prefixName to prefixName & i & " - "with my 1 liner... i would also replace
set alreadyNumbered to true
repeat with j from 1 to 4
if character j of oldPhotoName is not in {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} then
set alreadyNumbered to false
end if
end repeat
if (" - " is not (characters 5 thru 7 of oldPhotoName as string)) and not alreadyNumbered then
set the name of item i of thePhotos to prefixName & oldPhotoName
set renamedNumber to renamedNumber + 1
end if
with
try -- resort to cli cuz a/s sux 4 pattern matching;-} do shell script " echo "& quoted form of (oldPhotoName as string) & " | egrep '^[0-9]* - '" set the name of item i of thePhotos to prefixName & oldPhotoName set renamedNumber to renamedNumber + 1 on error -- dss throws exception when not found end try |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.06 seconds |
|