hi,
pulling hair out here. have rename series of images, placed in folder containing 100 sub-folders containing images. each sub-folder contains maximum of 5 images , need retain folder name in new file names.
example:
'fruit' folder contains images:
1.png
2.png
3.png
need file names saved in new group folder named as:
fruit-1.png
fruit-2.png
fruit-3.png
if select multiple folders achieve amazing, if have 1 one without having type folder name in every time good!
appreciated. picturesque, automator , photoshop can't unless i'm missing something?
thanks, nick
try this
code:
<?php //before //folder // folder1 // 1.jpg // 2.jpg // folder2 // 1.jpg // 2.jpg //******************** //after //folder // folder1 // folder1_1.jpg // folder1_2.jpg // folder2 // folder2_1.jpg // folder2_2.jpg foreach(glob('c:/folder/*', glob_onlydir) $dir) { $dirs = explode("/",$dir); $files = scandir($dir); foreach($files $file) { if (!is_dir($file)) { $old_name = $dir . '/' .$file; $new_name = $dir . '/' . $dirs[2].'-'.$file; rename($old_name, $new_name); } } } ?>
Forums Special Interests Web Design and Development
- iPhone
- Mac OS & System Software
- iPad
- Apple Watch
- Notebooks
- iTunes
- Apple ID
- iCloud
- Desktop Computers
- Apple Music
- Professional Applications
- iPod
- iWork
- Apple TV
- iLife
- Wireless
No comments:
Post a Comment