Solved

Need a script file to create a new folder and move contents from old location

Posted on 2014-01-21
4
841 Views
Last Modified: 2014-01-23
I have a few thousand folders with .pdf and .mov files in them. Some of the folders only have one file or the other as well.   I need to move the .mov files to a network share but I need the same folder name that the file is in now, to be created on the network share, and then the .mov files to be moved into that folder.   I need the old folder to stay if it has a .pdf(s) in it, but be deleted it if only had .mov files in it and is now empty.  These .mov files are not movies but medical documentation.  :)
Thanks for any guidance.
0
Comment
Question by:digital0g1c
4 Comments
 
LVL 18

Accepted Solution

by:
Dennis Aries earned 500 total points
ID: 39799294
How about simply using xcopy?

To copy all files recursively excluding pdf-files:
xcopy <source> <destination> /EXCLUDE:.pdf /S /I  

Open in new window


Delete all .mov-files recursively
del /S *.mov

Open in new window


Delete all empty directories:
Create a bat-file with the following line:
for /f "usebackq" %%d in (`"dir /ad/b/s | sort /R"`) do rd "%%d"

Open in new window


this will remove all empty directories recursively (taken from MSDN)
0
 
LVL 54

Expert Comment

by:Bill Prew
ID: 39799740
Is there just one level of folders, or are there folders withing the folders?

~bp
0
 
LVL 1

Author Closing Comment

by:digital0g1c
ID: 39804336
This worked great.   One thing is in the /EXCLUSION:.pdf needs to be /EXCLUSION:file.txt where file.txt is just a text file that has the exclusion files one per line like .pdf .txt ,etc.  Worked great though!  Thanks for your help!
0

Featured Post

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

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

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

713 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