Solved

Need a script for moving files with a specific format

Posted on 2013-06-05
4
284 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 52

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 39222229
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
ID: 39222304
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
ID: 39222694
worked perfectly. Thanks!!
0
 
LVL 52

Expert Comment

by:Bill Prew
ID: 39222809
Great, glad that was helpful, thanks for the feedback.

~bp
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

862 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

25 Experts available now in Live!

Get 1:1 Help Now