Solved

Need a script for moving files with a specific format

Posted on 2013-06-05
4
283 Views
Last Modified: 2013-06-05
I need a script that will scan an entire directory for every file with a .wav extention. Take that file and move it to a new location that I can specific like (C:Temp)

Any suggestions?

Thanks.
0
Comment
Question by:dowhatyoudo22
  • 2
  • 2
4 Comments
 
LVL 51

Accepted Solution

by:
Bill Prew earned 500 total points
Comment Utility
Do you want to preserve the file structure, or rather place all the files from the various subfolders into a single folder?  Here's a couple of approaches in one BAT file, use the one desired depending on the answer to this question.

@echo off
set BaseDir=c:\source
set DestDir=c:\temp

REM Use these two lines if you want to preserve folder structures
xcopy "%BaseDir%\*.wav" "%DestDir%" /S /I
del /S /Q "%BaseDir%\*.wav"

REM Use this line if you want to "flatten" all files to the dest folder
for /F "tokens=*" %%A in ('dir /S /B /A-D "%BaseDir%\*.wav"') do move "%%~A" "%DestDir%"

Open in new window

~bp
0
 

Author Comment

by:dowhatyoudo22
Comment Utility
Thats exactly what I am trying to do. Currently the .wav files are scattered across hundreds maybe thousands of different subfolders. I need to grab them all and place them all in one folder. I do however need to keep the filenames in tact as they are descriptive towards the actual .wav file itself.
0
 

Author Closing Comment

by:dowhatyoudo22
Comment Utility
worked perfectly. Thanks!!
0
 
LVL 51

Expert Comment

by:Bill Prew
Comment Utility
Great, glad that was helpful, thanks for the feedback.

~bp
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now