Batch file script to copy all matching files recursively.
Using the dir command and passing the values to the copy
command the script below is able to copy files recursively.
Script can be run via PowerShell using the Invoke-Command
cmdlet.
Invoke-command cmdlet with -Computer option and proper
privileges the script below can be used to copy files on a remote computer
provided that the correct path is specified.
Replacing the file name extension specified on “dir command”
(*.txt) the script is able to copy any files by replacing or specifying the
file extension.
Using PowerShell old batch file scripts if working properly
doesn't need to be re-written but can be easily integrated and used by
specifying Invoke-command and the batch file script filename.
To know more about the syntax of Invoke-Command, open
PowerShell ISE and type Get-Help Invoke-Command -Full. The output displayed
shows examples and explanation that can easily be followed.
Parameters explanation used on the batch file script:
dir d:\Txt_Logs\*.txt /B /S
d:\Txt_Logs\ - path specified for the text files
*.txt – read or find only this file extension
/B - Get the full path and the filename
/S - Do a recursive listing
To dig further at cmd line type: dir /?
xddmmyyyy=%date:~4,2%-%date:~7,2%-%date:~10,4% - gets the
date in day-month-year format
REM - means Remarks and batch file does not execute this
line
To know more about using dates on batch file check out this
link:
http://quickbytesstuff.blogspot.sg/2014/04/batch-file-date-format.html
http://quickbytesstuff.blogspot.sg/2014/04/batch-file-date-format.html
Here's the batch file script to copy files recursively:
===================================
REM get the current date when the batch file is executed
set
xddmmyyyy=%date:~4,2%-%date:~7,2%-%date:~10,4%
REM creates a new directory and uses the current date as
folder name
md E:\File_logs_backup\%xddmmyyyy%
REM Do a recursive listing on the directory specified and copies
all matching files
FOR /f "tokens=*" %%x in ('dir D:\Txt_Logs\*.txt
/B /S') DO copy /y %%x E:\File_logs_backup\%xddmmyyyy%\
===================================
Cheers..till next time..
Cheers..till next time..
===================================
Linux Android App cheat sheet:
https://play.google.com/store/apps/details?id=com.LinuxMobileKit
Free Android Apps:
Click on links below to find out more:
https://play.google.com/store/apps/details?id=soulrefresh.beautiful.prayer
Catholic Rosary Guide for Android:
https://play.google.com/store/apps/details?id=com.myrosaryapp
http://quickbytesstuff.blogspot.sg/2014/09/how-to-recite-rosary.html
Divine Mercy Chaplet Guide (A Powerful prayer):
https://play.google.com/store/apps/details?id=com.dmercyapp
Educational Android App for Kids:
https://play.google.com/store/apps/details?id=com.xmultiplication
https://play.google.com/store/apps/details?id=com.letsmultiply
Comments
Post a Comment