0
Thanks

A few words of thanks would be greatly appreciated.

Writing a script to move files




Issue


I need to write a script that will search a directory and its subfolders for *.txt files and *.tiff files, each .txt file having a corresponding .tiff file, the files will be located in different folders within the directory which will be stored in a network drive (file server). After locating the files I need to move them in to a new folder together. Can anyone help with this, I'm new to coding and could use some help.

Solution


You can use regular dos commands to create the list of files you need by using the dir command. Go to the folder where you want to start looking for files in your command prompt and type:

dir /b /s *.txt *.tiff > file_list.txt 


This will create a file "file_list.txt" listing all the txt and tiff files in that folder and subfolders. Once you have this list, you can use any language to create a copy from to process. I can create a quick PHP page if needed to do this.

Note


Thanks to Joey for this tip on the forum.
0
Thanks

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Related

This document, titled « Writing a script to move files », is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).

0 Comments