Copy All PDFs in a folder and all subfolders to a new folder using R
Using list.files
you can get complete path of all the pdf files in the main folder as well as sub folders. Then use file.copy
to copy all the pdf files to new folder (called New_folder
here).
all_pdf <- list.files('main/folder', pattern = '\\.pdf$', recursive = TRUE, full.names = TRUE)
file.copy(all_pdf, 'New_folder/')
How to copy all files in the subfolder
Use the xcopy
command. You can go to a command prompt and type xcopy /?
to get help using it.
For your particular question, the full command would be:
xcopy c:\sourcefolder\*.pdf c:\destinationfolder\ /e
Move every PDF file inside directory (and subdirectory) to another folder
Here's an applescript method. Using "entire contents" in the command makes it also search subfolders.
set theFolder to path to downloads folder from user domain
set destFolder to choose folder
tell application "Finder"
set thePDFs to files of entire contents of theFolder whose name extension is "pdf"
move thePDFs to destFolder
end tell
Copy pdfs in a directory to folders with the same name as the PDFs
You can use pathlib
and shutil
to perform this:
from pathlib import Path
from shutil import move
path_to_files = Path(r"C:\tmp\all_files_converted")
for pdf_path in path_to_files.glob("*.pdf"):
dir_path = path_to_files / pdf_path.stem
dir_path.mkdir()
move(pdf_path, dir_path / pdf_path.name)
Related Topics
How to Preserve Command Line Spaces in a Linux Application
Issue While Validating Bash Script
How to Install Crontab on Centos
How to Give a Linux User Sudo Access
How to Check That Two Folders Are the Same in Linux
How to Do Http-Request/Call with JSON Payload from Command-Line
How to Prevent Grep from Printing a Trailing Newline
Gpg: Sorry, No Terminal at All Requested - Can't Get Input
How to Make Find and Printf Works in Bash Script
How to Setup the Passwords-Less Authentication Between Two Different Accounts
How to Get Diff Between All Files Inside 2 Folders That Are on the Web
JSON Command Line Formatter Tool for Linux
How to Delete a User in Linux When the System Says Its Currently Used in a Process