Last active
December 15, 2015 06:28
-
-
Save AriTheElk/5216118 to your computer and use it in GitHub Desktop.
Recursively searches for files with the specified extension in the source folder and moves them into the destination folder. You can replace "fileExtension == extension" with "fileExtension != extension" to move every file except for the specified extension.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, os | |
source = "./Source_Folder/" | |
destination = "./Destination_Folder/" | |
extension = ".xml" | |
fileList = [] | |
for root, folders, files in os.walk(source): | |
for f in files: | |
fileName, fileExtension = os.path.splitext(os.path.join(root,f)) | |
if (fileExtension == extension): | |
fileList.append(os.path.join(root,f)) | |
for f in fileList: | |
os.rename(f,destination + f.split('/')[-1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment