Not quite programming but....

xtpunkerz

n00b
Joined
Nov 10, 2004
Messages
5
I'm trying to create a batch that moves .tif images from one directory to another, after those have copied it will then copy a .dat file to the same directory. Then move on to the next directory. I'm a little confused on how I go about this because all I've done is very basic, simple batches and I'm not sure how to begin with this task.
Below is an example of my directory structure.
------------------------------------------------------------------------


------------------------------------------------------------------------

I'm wanting the batch to go into the XXXX directory in the ProcessedBatches directory, copy every .tif file within that directory, move it to a destination directory, then copy the .dat file in the XXXX directory, move that into the destination directory, and then move on to the next directory within the root of ProcessedBatches directory and repeat the same process.

------------------------------------------------------------------------

This may seem like an overwhelming amount of information, maybe it is. I'm not asking you to write the actual code for me (if you did i'd love you forever though.) .... I'm just looking for someone who may be able to point me in the right direction on where to begin (yes, I've browsed through example batch files and searched the forum)

Thanks for any help you give me!

--drpunkerz
 
Another option you may want to consider is you can write a Perl script to do the work. Use a loop to grab each file in the XXXX folder and move it to the desired directory, and another to go through the directory structure (form XXXX1 to XXXX2). I guess this only helps if you know Perl, but I find Perl much easier to use than batch files. If you know how to program you could pick it up quick enough to do this task. Also, you can get ActiveState perl for free on your PC. The added benefit is that, if you must have this as a batch file, you can use perl2bat to convert your perl script to a batch file. Hope this helps.
 
screwmesa said:
move c:\pictures\*.tif s:\pictures

that might get you started...

Yes! I love useless information. :rolleyes:

CefiroZ said:
Another option you may want to consider is you can write a Perl script to do the work. Use a loop to grab each file in the XXXX folder and move it to the desired directory, and another to go through the directory structure (form XXXX1 to XXXX2). I guess this only helps if you know Perl, but I find Perl much easier to use than batch files. If you know how to program you could pick it up quick enough to do this task. Also, you can get ActiveState perl for free on your PC. The added benefit is that, if you must have this as a batch file, you can use perl2bat to convert your perl script to a batch file. Hope this helps.

I'm still pretty much a newbie to programming so that wont work very well for me but thank you very much for the idea and information.

If anyone else has useful suggestions or ideas please reply.

--drpunkerz
 
i 2nd the perl post. relatively easy with basic programming knowledge. if your inunformed about perl, give it a shot and youll pick it up quickly. it will take a little understanding and playing, but afterwards, you have a new skill that you can work with. definately useful for the internet
 
like others said, perl is very useful, but if you don't want to muck with that, download cygwin and get some USEFUL command line tools that you will actually be able to do something with.

then something like:

Code:
ls -p | grep / | xargs -J % mv %*.tif %.. && mv %*.dat %..

ought to do the trick.

(this may or may not work, i haven't tried it)
 
cair0 said:
then something like:
Code:
ls -p | grep / | xargs -J % mv %*.tif %.. && mv %*.dat %..
I've looked on three different systems (Cygwin, Gentoo, and (effectively) SGI), and none of them have a -J option. Look like that's basically the same as -i% (or --replace=%), if I understand your intent.
Code:
ls -1p | grep '/$' | xargs --replace=% bash -c "mv %*.tif %.. ; mv %*.dat %.."
...might come closer to working. :) Anyway, I agree. Get Cygwin; this is exactly the kind of thing you need a command line for. Why write an entire program in perl when one little command line can do what you need?
 
HorsePunchKid said:
I've looked on three different systems (Cygwin, Gentoo, and (effectively) SGI), and none of them have a -J option. Look like that's basically the same as -i% (or --replace=%), if I understand your intent.
Code:
ls -1p | grep '/$' | xargs --replace=% bash -c "mv %*.tif %.. ; mv %*.dat %.."
...might come closer to working. :) Anyway, I agree. Get Cygwin; this is exactly the kind of thing you need a command line for. Why write an entire program in perl when one little command line can do what you need?


ahh, yeah apparently it's darwin (aka os x) specific
 
I think you could do this in Windows batch scripting using the for command.
Something like this (untested):

Code:
@ECHO OFF
set %dir = e:\processedbatches
FOR /D %%dir IN (%dir) DO call :CopyFiles %%dir
goto :eof

:Copyfiles
copy %dir\*.log "path\to\destination\directory"
copy %dir\*.dat "path\to\destination\directory"
 
Back
Top