Writing a script to move files

October 2016


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.


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.


Thanks to Joey for this tip on the forum.

Related :

This document entitled « Writing a script to move files » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.