![]() |
I wonder if we aren't making too much of the memory gains. I tried running the vm_stat a few times in a row and found that the pages free can fluctuate quite a bit without doing anything (except running programs in the background)...
|
Batch operations in UNIX?
I think I found one place where memory is getting hogged and I have an idea about how to fix it, but I need UNIX help!
I tried to keep everything as simple as possible. First I changed my ImageMagick command to output mulitple PBM (portable bitmap) files instead of one single file. Then, I restarted my machine and ran the command: Code:
nice +10 convert -compress zip *.pbm tiff:output%02d.tiffThese PBM files are about 500K each, and after it went through 29 of the 59 files, I got this error: Quote:
Now, what I realize in using +adjoin in ImageMagick is that it seems to first do all the conversions in memory (for all the files) and then to write them to disk afterwards!!! What I would like to know how to do is to tell ImageMagick to do this for one file at a time! Something like: For each file *.pbm Convert to compressed Tiff Renaming with the same name but changing the extension. I imagine that there is a UNIX command for this but I don't know where to look - especially for the naming part! TIA! |
What about a simple foreach loop: that might start/stop imagemagick once per file, thus leaving lighter footprints.
% foreach file (*.pbm) foreach? nice +10 convert -compress zip $file (etc etc) foreach? end Worth a go! Cheers, Paul (You can of course throw this into a file --say "scriptname" with #!/bin/sh on the first line (and no "foreach?" on lines 2 and 3; the shell adds these in when you do this interactively), then make it executable and just use ./scriptname to run it) |
better use #!/bin/csh with foreach
sh no got foreach sh has: for NAME [in WORDS ... ;] do COMMANDS; done for file in /path/to/*.pbm; do nice...; done |
Getting there!
Amazing. This is definately the way to go! It was much faster, and it did all the files without error.
I want to sort out one more thing before I go trying to write a script for this (I'm still doing it manually), and that is get the process of file naming using the "foreach" command down. I tried reading the man (I really did), but what I came up with is this and it doesn't work: Code:
% foreach file ( *.pbm )Thanks. |
Re: Getting there!
Quote:
And yes, that is a space after $file. (Is it '.tif' you want or '.tiff'? You say both :-) ) hth |
Great. In another thread someone suggested "basename" but I didn't notice that it required a space. Now it works! Such small things. Thanks about the tif/tiff thing too. Doesn't really matter as far as I can tell, but it is good to be consistent!
|
Now the question is how to get this script to work not on the top level folder, but for all the sub-folders in it. That is, I have a folder called "scans" and it contains multiple folders "scanfolder 1" "scanfolder 2" etc. How do I get the script to operate on the TIF files inside each of these folders, rather than just the top level?
Code:
#! /bin/csh |
Full script (but problems remain)
I haven't solved the issues from my last post, but here is the full script as it now stands:
Code:
#! /bin/csh |
Got it! (Almost)
I finally got the recursive directory thing! Now I just need to figure out why it isn't accepting spaces in directory paths...
Here is the final script. All I intend to do now is fix some of the feedback, and set it to work with fixed top-level directories. I want to have one directory called "portrait" and one called "landscape" - that way I can simply save scans to the appropriate directory and the script will treate them each correctly. When done I will post back here. But for now, this is what I have: Code:
#! /bin/csh |
would this make sense if you run du on a system that seems to become sluggish to avoid a crash? I mean if you catch it early enough?
|
although not a unix solution, I just deleted my loginwindow plist files and the system seems to be handling memory much better.
|
| All times are GMT -5. The time now is 06:12 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.