Need help with looping over directories
-
- Posts: 8
- Joined: 2013-11-19T05:23:43-07:00
- Authentication code: 6789
Need help with looping over directories
Could someone provide the code for looping through directories? I'd like to convert my (40 GB total!) uncompressed TIFFs to LWZ-compressed TIFFs but maintaining directory structure/hierarchy.
Last edited by seanspotatobusiness on 2014-05-13T02:44:44-07:00, edited 1 time in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Need help watermarking images in Image Magick!
Code depends upon your OS (Windows or Unix)? Also what version of IM are you using?seanspotatobusiness wrote:Could someone provide the code for looping through directories? I'm in a similar situation with respect to maintaining directory structure/hierarchy except I want to convert my (40 GB total!) uncompressed TIFFs to LWZ-compressed TIFFs.
In the future, please start a new topic rather than tacking onto an old one. Also please read viewtopic.php?f=1&t=9620
-
- Posts: 8
- Joined: 2013-11-19T05:23:43-07:00
- Authentication code: 6789
Re: Need help with looping over directories
I'm using Windows 7 and ImageMagick version is 6.8-7.6 Q16 x64 2013-11-07.
I thought my query was still relevant to the older thread because although the solution of looping over directories was mentioned, there was no indication of how that should be done.
I thought my query was still relevant to the older thread because although the solution of looping over directories was mentioned, there was no indication of how that should be done.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Need help with looping over directories
IM contains a "mogrify" command for processing multiple files files in one directory, but it won't walk a directory tree. So you need to use an operating system facility for that.
I would use "for" to get individual files, and "convert" to convert one at a time. Type "for /?" for help. For example, at the command line:
Instead of echo, you would have a convert command, which would depend on exactly what you want to do. For example "convert %F -compress LZW %F" would compress each file, overwriting it. You might prefer to create copies in a separate directory structure.
I would use "for" to get individual files, and "convert" to convert one at a time. Type "for /?" for help. For example, at the command line:
Code: Select all
for /F %F in ('dir /b /s *.tiff') do echo %~dpF %~nF
snibgo's IM pages: im.snibgo.com