Create Batch script to copy specific files from one folder to another - batch-file

I am attempting to copy specific files from one folder to another. The files in the source folder may have a names like:
1FT_DINRM_TASCAM_pt5GAL_TCL_cpl.wav
1FT_DINRM_TASCAM_pt5GAL_TCL_lcpl.wav
1FT_DINRM_TASCAM_pt5GAL_TCL.wav
I just want to copy the files that have cpl and lcpl in their names.
I am not sure how to implement this in the batch script that is currently at this stage:
mkdir Modified_originalClip
set "source=G:\Personal Data\Unclipped"
set "destination=G:\Personal Data\Modified_originalClip"
robocopy "%source%" "%destination%" /mov /minage:%X%
Any help to copy the specific files in the Windows 10 environment will be sincerely appreciated!

Related

batch file to copy files to newly created folder with date name

I'm making a system that our employees need to store files to that are ment to be processed. This process however deletes the source files and I want to make a backup prior to these files being processed.
The files need to be stored in an automatically created folder with name being today's date. The files vary in filetype.
The first part, creating a folder with today's date, I managed to figure out. The second part, copying files from a general folder to this newly created folder is something I can't get to work.
This is the code I have so far
#echo off
set date="%date:~-10,2%-%date:~-7,2%-%date:~-4,4%"
set "source=C:\b2g\2021\general"
set "destination=C:\b2g\2021\%date%"
mkdir "C:\b2g\2021\%date%"
robocopy "%source%" "%destination%" /mir /minage:%X%
exit /b
This is creating the folder, but is not copying any files to that folder.
any help is very kindly apreciated

BATCH - how to perform cyclic copy only for specific substring of folder name/file name?

I have a folder [C:\Users\name\desktop\New_Folder] with multiple folders and files. e.g.
New_Folder
uuu_folder
abcd_folder
abcd_2_folder
abcd_3_folder
nnn.docx
bbb.xlsx
I managed to "xcopy" all the files and folders in this folder to another folder. But, how can only "xcopy" the folders with only name started with abcd which only abcd_folder, abcd_2_folder and abcd_3_folder have copied?
set A_LOCAL=C:\Users\name\desktop\New_Folder
set B_LOCAL=C:\Users\name\desktop\Archive_Folder
set LIST=abcd
This is working for copying all the files and folders.
xcopy "%A_LOCAL%\*" "%B_LOCAL%\" /E
But this is not working for copying folders with specific subname of the folders?
xcopy "%A_LOCAL%\%LIST%_*" "%B_LOCAL%\" /E
Please help.

Destination Folder Batch file

I currently use a .bat file
I'm able to copy a test.cfg file in a folder named testVersion434 using copy test.cfg testVersion434.
Unfortunately I am unable to copy the file test.cfg to a folder that begins with testXXXXXXXX
I'll have in the future Folders testVersion43x that will create , and I would copy test.cfg in all folders who begin with test
I can list all of them with dir test*
You will need to enumerate the target folders and execute a copy operation for each one
for /d %%a in ("c:\folders\test*") do copy "c:\file\test.cfg" "%%~fa"
The for /d command will iterate over the indicated set of folders and, for each one, the code after the do clause is executed, with %%a holding a reference to the folder being iterated. %%~fa is the full path of the folder.

.bat coding or some app maybe?

how can I organize my directories automatically?, I have a "downloads" folder, which currently contains lots of different info, for example, work related info, tv-shows, movies, etc, software, etc.
How can I automatically, maybe using some .bat execution, not sure, check for example the name of the files, or the type, and put them in the right subfolders?.
Thanks!.
You can use the move command to move files. You can also use wildcards in it.
So you could write a batch script that looks something like this:
cd C:\Users\You\Downloads
rem Excel sheets are work.
move *.xls Work
rem Reports are work.
move Report*.pdf Work\Reports
rem Pron and other viewing material ;)
move *.mp4 Private
You could run this script automatically by making it a scheduled job. Note that this script changes to the right directory first and then moves items to a relative subdirectory. This means that the directories Work, Work\Reports and Private must exist in the Downloads directory.
Of course you can expand the script to make it check and create directories as well, or you can specify different paths if you want to move the files out of the Downloads directory.
Basically, try to do it on the command line and then try to generalize those steps into your script.
This batch file will create a set of folders like .mkv .jpg .mp3 using the filetypes inside the folder, and move the files into the appropriate folders.
Launch it from your desktop and change the "c:\media" to the right folder name.
#echo off
cd /d "c:\media" && for %%a in (*) do md "%%~xa" 2>nul & move "%%a" "%%~xa" >nul

Batch file to create Folder based on Date and Copy Files from One Location to Another Location?

I want to Copy/Move files in Windows XP from Desktop(a Folder) to My Document(another Folder), which was created by same Batch File on Current Date in Format DD/MM/YYYY.
This is working fine when .BAT File is in Desktop Folder.
#echo off
set date="%date:~7,2%-%date:~4,2%-%date:~10,4%"
mkdir %date%
copy *.txt \%date%
pause
Now what this .BAT is doing is, creating Folder 18-01-2013 on Desktop and coping all .TXT files in this Folder.
But this is not working,
#echo off
set date="%date:~7,2%-%date:~4,2%-%date:~10,4%"
mkdir %USERPROFILE%\My Documents\%date%
copy %USERPROFILE%\desktop\*.txt %USERPROFILE%\My Documents\%date%
pause
This .BAT File is creating these folders;
1. In C Drive>Documents
2. On Desktop (and, Chandel>My, Documents>18-01-2013, Settings>Anshuman)
Any help in this regard is highly appreciated!
Try putting lines that has file/folder names with spaces in quotes e.g. update this line
mkdir %USERPROFILE%\My Documents\%date%
to
mkdir "%USERPROFILE%\My Documents\%date%"

Resources