Reputation: 419
I'm trying to write a function which will allow me move .xlsm files between folders. I'm aware I can use shutil.move(), however, I'm trying to build a function that will take a file path as a parameter/argument and then perform the procedure.
Here's what I have:
def FileMove(source):
import os
import shutil
source = 'C:\\Users\\FolderB\\'
archive = 'C:\\Users\\FolderA\\'
UsedFiles = os.listdir(source)
for file in UsedFiles:
shutil.move(source+file, archive)
This doesn't do anything. Just wondering if anyone could point me in the right direction
Cheers
Upvotes: 2
Views: 78
Reputation:
So just delete def FileMove(source):
and it works fine.
Or you do something like that:
import os
import shutil
def FileMove(source):
archive = 'C:\\Users\\FolderA\\'
UsedFiles = os.listdir(source)
for file in UsedFiles:
shutil.move(source+file, archive)
source = 'C:\\Users\\FolderB\\'
FileMove(source)
Upvotes: 2