I have a list of multiple specific directories that I would like to move to another folder on Windows. The list is stored in a txt.file which contains the paths of these directories:
"C:/Path/to/my/folder1/"
"C:/Path/to/my/folder4/"
"C:/Path/to/my/folder9/"
I would like to move all these folders including there subfolders to a new directory:
C:/Path/to/new/directory/
Is there a smart way to do this by powershell, python or R on windows?
Edit (Sorry, didn't include my first attempts initially):
I had previously tried using the "file.copy(list_of_paths, target_path
)" command in R, but it always returned "FALSE FALSE". If I understood correctly, it seems that R on windows has difficulties handling folders rather than files (I'm used to unix and haven't come across that issue before).
The other thing I tried was using the Copy-Item command on Powershell (Get-ChildItem -Path 'C:\Path\of\files' -Recurse| Copy-Item -Destination 'C:\Path\to\target'
), but I'm not sure how to load a list of paths in Powershell.
Thanks so much!
CodePudding user response:
Here is a solution using R. Assuming that your filepaths are stored in a list fpath
:
file.copy(fpath, "C:/Path/to/new/directory/")