I'm trying to write a small python script to fix the capture date of my videos. I'm on Windows and I want to use the "SendTo" feature.
So far I'm just trying to get a list of video files based on the command line arguments:
import argparse
import os
vidExtension = "mp4"
def getVideoFiles(fileFolders):
files=[]
folders=[]
# Create list of folders and files from command line arguments
for arg in fileFolders:
curpath = os.path.normpath(arg)
print(curpath, os.path.isdir(curpath))
if os.path.isdir(curpath):
folders.append(curpath)
elif os.path.isfile(curpath):
if curpath.lower().endswith(vidExtension):
files.append(curpath)
else:
print("Unrecognized arg: " + arg + "\n normpath: " + curpath)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Process video files')
parser.add_argument('foldersFiles', type=ascii, nargs='+',
help='Folders/Files to process')
args = parser.parse_args()
print(args.foldersFiles)
getVideoFiles(args.foldersFiles)
When launching the script (right clic SendTo...), here is the output I get:
args.foldersFiles: ["'D:\\\\Synchro NAS\\\\Images\\\\Photos Num\\xe9riques\\\\A Trier\\\\2020\\\\z Videos\\\\temp'", "'D:\\\\Synchro NAS\\\\Images\\\\Photos Num\\xe9riques\\\\A Trier\\\\2020\\\\z Videos\\\\00047.mp4'"]
'D:\Synchro NAS\Images\Photos Num\xe9riques\A Trier\2020\z Videos\temp' isdir: False isfile: False
Unrecognized arg: 'D:\\Synchro NAS\\Images\\Photos Num\xe9riques\\A Trier\\2020\\z Videos\\temp'
normpath: 'D:\Synchro NAS\Images\Photos Num\xe9riques\A Trier\2020\z Videos\temp'
'D:\Synchro NAS\Images\Photos Num\xe9riques\A Trier\2020\z Videos\00047.mp4' isdir: False isfile: False
Unrecognized arg: 'D:\\Synchro NAS\\Images\\Photos Num\xe9riques\\A Trier\\2020\\z Videos\\00047.mp4'
normpath: 'D:\Synchro NAS\Images\Photos Num\xe9riques\A Trier\2020\z Videos\00047.mp4'
Files and folders are not recognized. I used os.path.normpath to normalize the paths but it doesn't work...
An important notice is that I have accentuation in the path string: The real path is: D:\Synchro NAS\Images\Photos Numériques\A Trier\2020\z Videos
Could someone help me please :)!