Concatenate text in batch - batch-file

I have sql files in a folder structure like the following :
C:\Users\Peter\Desktop\SQL_FILES\data_structure\customer1\test.sql
C:\Users\Peter\Desktop\SQL_FILES\data_structure\customer2\test.sql
C:\Users\Peter\Desktop\SQL_FILES\data_structure\customer3\test.sql
C:\Users\Peter\Desktop\SQL_FILES\data_structure\customer4\test.sql
........
I want to make a script which reads the path (C:\Users\Peter\Desktop\SQL_FILES),
the name of the file(test.sql) and a text
and then concatenate the text in the end of each test.sql file.
Could you help me please ?
Thanks in advance
:: Hide Command and Set Scope
#echo off
setlocal EnableExtensions
mode 140,50
set /p AbsolutePath="Enter the path of root folder :"
echo.
set /p FileName="Enter the filename with it's extension (ie. test.sql):"
echo.
echo Enter your inserts
echo Press Enter twice when finished
echo (text may not contain ^<, ^>, ^|, ^&, or un-closed quotes)
ver > NUL
set new_line=""
:still_typing
set /p new_line=">"
if errorlevel 1 echo. >> temp.txt & set /p new_line=">"
if errorlevel 1 echo Sending message. . . & goto done_typing
echo %new_line% >> temp.txt
goto still_typing
:done_typing
echo done
:End
endlocal
pause >nul
=====================================
For example :
The file test.sql for example contains initially :
INSERT INTO TEST(COL1,COL2,COL3) VALUES(3,4,5);
And after the execution of batch supposing I add an empty line and two inserts in the text :
INSERT INTO TEST(COL1,COL2,COL3) VALUES(3,4,5);
INSERT INTO TEST(COL1,COL2,COL3) VALUES (1,2,3);
INSERT INTO TEST(COL1,COL2,COL3) VALUES (2,3,4);

The Batch file below use a different method to do the same, but in a simpler way. This code may be modified in any point you wish; for example, if you want not that the filename must include a wild-card.
#echo off
setlocal
set /p "AbsolutePath=Enter the path of root folder: "
echo/
set /p "FileName=Enter the filename with a wild-card (ie. test*.sql): "
echo/
echo Enter your inserts
echo Press Ctrl-Z and Enter when finished
copy CON temp.txt > NUL
echo/
echo Typing done
echo/
for /R "%AbsolutePath%" %%a in (%FileName%) do type temp.txt >> "%%a"

Related

batch download images from url with for

I need to download 300 images from site.com/folder/ using the following format: 1.png, 2.png ... 300.png
Is there a way to do this inside a batch file or using the command prompt?
Wth curl like this:
curl -o "#1.png" http://example.com/folder/[1-300].png
Here is an example to download some batch codes from a file that can be created by this script if not exist, and of course you can add or modify what you want of urls in this file !
You can add your urls in the text file named Urls.txt
Firstly, the script check for the text file named Urls.txt if exist in same location where this batch is executed and read from it the urls line by line to download them !
So, if you want to change those urls to yours, just change it from the text file Urls.txt not from the batch, i mean you can create a text file and name it to Urls.txt and put what you want as urls on this file line by line of course and let the script do its job
#echo off
Mode 110,3 & color 0A
Title Download file from web using powershell and batch by Hackoo 2017
Set "List_Urls_File=Urls.txt"
If not exist "%List_Urls_File%" Call :Create_Urls_File
Setlocal enabledelayedexpansion
#For /f "delims=" %%a in ('Type "%List_Urls_File%"') do (
Set "URL=%%a"
Rem we set the Filename from the variable !url!
#for %%# in (!url!) do ( set "File=%%~xn#" )
Rem Check if the file name contains a dot "."
Rem If not we increment the counter +1 for file to be download
ECHO !File! | FIND /I ".">Nul 2>&1
If "!errorlevel!" NEQ "0" (
Set /a Count+=1
cls & echo(
echo Downloading file "File-!Count!.bat" from URL : "!URL!"
Call :BalloonTip 'information' 10 '"Downloading File-!Count!.bat"' "'Please wait... Downloading File-!Count!.bat....'" 'info' 4
Call :Download "%%a" "File-!Count!.bat"
) else (
cls & echo(
echo Downloading file "!File!" from URL : "!URL!"
Call :BalloonTip 'information' 10 '"Downloading !File!"' "'Please wait... Downloading !File!....'" 'info' 4
Call :Download "%%a" "!File!"
)
)
Explorer "%~dp0" & exit
::*********************************************************************************
:Download <url> <File>
Powershell.exe -command "(New-Object System.Net.WebClient).DownloadFile('%1','%2')"
exit /b
::*********************************************************************************
:Create_Urls_File
(
echo https://pastebin.com/raw/XvyhRzT6
echo https://pastebin.com/raw/QqnZ0MjQ
echo https://pastebin.com/raw/tHsKw15V
echo https://pastebin.com/raw/VCnTbLB6
echo https://pastebin.com/raw/3zUTrWUz
echo https://pastebin.com/raw/31auQeFz
echo https://pastebin.com/raw/xF0uXThH
echo https://pastebin.com/raw/uzsGQD1h
echo https://pastebin.com/raw/3TmVYiZJ
echo https://pastebin.com/raw/Ntc8SZLU
echo https://pastebin.com/raw/jnpRBhwn
echo https://www.virustotal.com/static/bin/vtuploader2.2.exe
echo http://devbuilds.kaspersky-labs.com/devbuilds/KVRT/latest/full/KVRT.exe
)>"%List_Urls_File%"
exit /b
::*********************************************************************************
:BalloonTip $notifyicon $time $title $text $icon $Timeout
PowerShell ^
[reflection.assembly]::loadwithpartialname('System.Windows.Forms') ^| Out-Null; ^
[reflection.assembly]::loadwithpartialname('System.Drawing') ^| Out-Null; ^
$notify = new-object system.windows.forms.notifyicon; ^
$notify.icon = [System.Drawing.SystemIcons]::%1; ^
$notify.visible = $true; ^
$notify.showballoontip(%2,%3,%4,%5); ^
Start-Sleep -s %6; ^
$notify.Dispose()
%End PowerShell%
exit /B
::*************************************************************************
Numbered-Files Downloader 1.0
Here is a complete batch script that is doing exactly what you asked for. You don't need to download any executable files, this is 100% batch script and it should works on any (recent) Windows installation.
All you need to do is to edit the _URL variable (Line 11) and replace "example.com/folder..." with the actual URL of the files you want to download. After that, you can run the script and get your files.
Note that in your URL, this string: _NUMBERS_ is a keyword-filter that will be replaced by the incremented numbers in the final download function.
All your downloaded files will be saved in the directory where this script is located. You can choose an other directory by uncommenting the _SAVE_PATH variable (Line 15).
Finally the following variables can be changed to configure the series of numbers:
_START : The file numbers starts with this value.
_STEP   : Step between each files.
_END    : The file numbers ends with this value.
Leading Zeros
Currently, the counter doesn't support leading zeros.
EX. From Picture_001.jpg to Picture_999.jpg
But otherwise it should work fine for something like this:
EX. From Picture_1.jpg to Picture_999.jpg
I will try to find some time to add this option, it shouldn't be too difficult.
Feel free to modify & enhance this script if you need!
Numbered-DL.cmd
#echo off
setlocal EnableDelayedExpansion
rem STACKOVERFLOW - QUESTION FROM:
rem https://stackoverflow.com/questions/45796990/batch-download-images-from-url-with-for
:VARIABLES
rem WHERE YOU WANT TO SAVE FILES
rem "%~dp0" is a variable for the same folder as this script, so files should be saved in the same folder.
rem If you want to save the downloaded files somewhere else, uncomment the next line and edit the path.
SET "_SAVE_DIR=%~dp0"
rem SET _SAVE_PATH=C:\Folder\
rem DOWNLOAD THIS FILE URL
rem
rem "_NUMBERS_" WILL BE REPLACED BY THE COUNTER
rem CURRENLY IT DOESN'T SUPPORT CHOOSING A NUMBERS OF ZEROS FOR THE COUNTER EX: 001,002,003...
rem BUT IT SHOULDN'T BE TOO HARD TO IMPLEMENT, MAYBE ILL ADD THIS IN THE FUTURE.
rem
rem SET _FILE_URL=https://example.com/folder/_NUMBERS_.png
SET "_FILE_URL=https://cweb.canon.jp/eos/lineup/r5/image/downloads/sample0_NUMBERS_.jpg"
rem FOR THIS EXAMPLE THE SCRIPT WILL DOWNLOAD FILES FROM "sample01.jpg" TO "sample05.jpg"
SET _START=1
SET _STEP=1
SET _END=5
:CMD_PARAMS
IF NOT [%1]==[] SET "_FILE_URL=%1"
IF NOT [%2]==[] SET "_SAVE_DIR=%2"
:PATH_FIX
rem REMOVE THE LAST CHAR IF IT IS "\"
IF [%_SAVE_DIR:~-1%] == [\] SET "_SAVE_DIR=%_SAVE_DIR:~0,-1%"
:DETAILS_DISPLAY
ECHO.
ECHO SCRIPT: Numbered-Files Downloader 1.0
ECHO AUTHOR: Frank Einstein
ECHO.
ECHO.
ECHO INPUTS
ECHO _URL: %_FILE_URL%
ECHO _SAVE_DIR: %_SAVE_DIR%
ECHO.
ECHO _START: %_START%
ECHO _STEP= %_STEP%
ECHO _END= %_END%
ECHO.
ECHO.
CALL :DOWNLOAD_LOOP
ECHO.
ECHO EXECUTION COMPLETED
ECHO.
PAUSE
EXIT /B
:DOWNLOAD_LOOP
SET FINAL_URL=%_FILE_URL%
FOR /L %%G IN (%_START%,%_STEP%,%_END%) DO (
rem REPLACE URL'S KEYWORD WITH NUMBERS
SET NUM=%%G
SET FINAL_URL=%FINAL_URL:_NUMBERS_=!NUM!%
rem CUMSTOM BATCH FUNCTION FOR DOWNLOADING FILES
rem
rem SYNTAX:
rem echo CALL :DOWNLOAD !FINAL_URL!
CALL :DOWNLOAD !FINAL_URL! !_SAVE_DIR!
)
Goto :EOF
rem PAUSE
rem EXIT /B
rem FUNCTIONS
:DOWNLOAD
setlocal
SET "DL_FILE_URL=%1"
SET "DL_SAVE_DIR=%2"
rem EXTRACT THE FILENAME FROM URL (NEED TO FIX THIS PART?)
FOR %%F IN ("%DL_FILE_URL%") DO SET DL_FILE_NAME=%%~nxF
IF "%DL_SAVE_DIR:~-1%" == "\" SET "DL_SAVE_DIR=%DL_SAVE_DIR:~0,-1%"
IF NOT [%2]==[] SET "DL_SAVE_FILE=%DL_SAVE_DIR%\%DL_FILE_NAME%"
IF [%2]==[] SET "DL_SAVE_FILE=%~dp0%DL_FILE_NAME%"
rem :BITSADMIN
ECHO.
ECHO DOWNLOADING: "%DL_FILE_URL%"
ECHO SAVING TO: "%DL_SAVE_FILE%"
ECHO.
bitsadmin /transfer mydownloadjob /download /priority foreground "%DL_FILE_URL%" "%DL_SAVE_FILE%"
rem BITSADMIN DOWNLOAD EXAMPLE
rem bitsadmin /transfer mydownloadjob /download /priority foreground http://example.com/filename.zip C:\Users\username\Downloads\filename.zip
endlocal
GOTO :EOF
try with winhttpjs.bat:
set "baseLink=http://example.org/folder/"
for /l %%a in (1;1;300) do (
winhttpjs.bat "%baseLink%%%a.png" -saveto %%a.png
)

Batch how to convert text document to variable

right now i'm working on a batch file that has a simple login and register feature. While I can register a user by creating a .txt file for their username and password, I cant figure out how to convert the contents of the .txt file into a variable that I can then test for to login the user. Here is what I have now. My problem is at :sign .
#echo off
title Login
:a
cls
mode con: lines=10 cols=25
echo _________________________
echo Select Your Choice
echo 1) Login
echo 2) Register
echo _________________________
set /p begi=:
if '%begi%'=='2' goto reg
if '%begi%'=='1' goto sign
:reg
cls
set u=
set /p u=Enter Your Username:
pause>nul
cls
set p=
set /p p=Enter your Password:
pause>nul
#echo %u% > user.txt
#echo %p% > pass.txt
pause>nul
goto a
:sign
cls
exit
REM write to the file:
echo Username>user.txt
REM read from the file (first line only):
set /p "un="<user.txt
echo %un%
by the way:
your line #echo %u% > user.txt writes the variable plus a space to the file. This space will be part of the new variable (and will make trouble when using the new variable), if you read this file in. To avoid it, write #echo %u%>user.txt

Batch file: save & load

I have one big problem. This app SHOULD ASK user for his name ONCE. It saves username and then when he run this app again 1st stage should be skipped and variable "name" should has his name from file with extension .user, but it does not work :/ Please Help!
#echo off
If NOT EXIST .settings md .settings
cd .settings
If NOT EXIST *.user goto abc
pause
If EXIST *.user set name=*.user
cd ..
pause
goto welcome
pause
:abc
cd ..
echo Hi! Welcome in my program!
set /p name=Tell me your name!
If NOT EXIST .settings md .settings
cd .settings
echo >>%name%.user
pause
:welcome
cls
echo Welcome %name%
pause
Other commands
EDIT: Pauses are only for me :)
You're just setting name to the string *.user. You need to parse the filename and extract just the first part.
Try:
If EXIST *.user (
for /f %%a in ('dir /b *.user') do (set name=%%~fa)
)
cd ..
Also, to just create a blank file, you can use
Type nul > %name%.user
It's not particularly clear what you are trying to do.
If fred has entered his name, this line:
echo >>%name%.user
will send the ECHO status (Echo is on/off) to the file fred.user
If you want the file .user to contain "fred" then you'd need one of
echo %name%>.user
>.user echo %name%
(personally, I'd use the second)
If you then want to read the user's name from the file .user then
set /p name=<.user
So all together, I'd try
#ECHO OFF
SETLOCAL
IF EXIST .user (SET /p name=<.user) ELSE (SET /p name=Your name ?)
>.user ECHO %name%
ECHO name is %name%
(I'll leave you to do the directory-manipulation)
Note that I've used > which means 'start a brand new filewhereas>>means 'append to an existing file or create a new file

Update a batch file from another batch file

Dear StackOverFlow Members,
Please help me with this batch file. I would like to use the answer given from the "SET /P INPUT=%=%" and have it update another batch file permanently.
This is the first batch file that runs to get an answer from the user
#echo off
cls
echo.
echo .................................................................
echo ..... Specify what the name of the Store is, this will send .....
echo ............... alerts to abd#abc.co.za ..............
echo .................................................................
echo.
pause
:option
cls
color 5E
echo.
echo "............ Press 1 to specify what the store name is......"
echo "............ Press 2 to exit the program ................."
echo.
SET /P M=Type from the menu above 1 or 2 then press ENTER:
IF %M%==1 GOTO SEND
IF %M%==2 GOTO EOF
:SEND
cls
color 0A
set INPUT=
set /P INPUT=Enter Store Name: %=%
if "%INPUT%"=="" goto input
echo "You said that the store name is: %INPUT%"
:: Have the user confirm his/her choice
SET /P ANSWER=Is the name correct (Y/N)?
echo You chose: %ANSWER%
if /i {%ANSWER%}=={y} (goto :yes)
if /i {%ANSWER%}=={yes} (goto :yes)
goto :no
:yes
echo You pressed YES!... The name is updating
goto name
:no
echo You pressed NO!... The program will exit
pause
cls
goto eof
:name
::set /A store=%INPUT%
echo %INPUT% >> notify_support.bat
::Terminate the program
:EOF
As you can see I am struggling to specify where I should "echo %INPUT% >> notify_support.bat". This is code taken from the second batch file
#echo off
call senditquiet -s smtp.gmail.com -port 587 -u rsupp0rt#gmail.com -protocol ssl -p access -f rsupp0rt#gmail.com -t 888#gmail.com -subject "Store ABC" -body "Hello there, There is an issue logged at the store.<br>Best regards."
When the first batch file runs, it updates the second one but just dumps it at the end of the file.
I need the INPUT ECHOed to replace "Store ABC" in the second batch file.
Please assist, I'm rather rusty with batch files.
echo %INPUT% >> notify_support.bat
That line contains >> which means 'dump at the end of the file'. You can use a single > to overwrite the existing file contents. That way, you can re-generate the whole file (which is only 2 lines anyway).
A different solution is to actually parse the exising file and replace that text. You can do that by using for /F ..., which allows you to traverse through the lines of a file. You can then generate a new file, based on the (altered) contents of the existing file. Disadvantage is that this file-parsing method is especially suitable for data files in which each line has the same format with fields and delimiters (like a CSV file). It is less suited for parsing 'complex' files like a batch file or program source file.
try the code:
#echo off
echo Welcome
echo > echo #echo off >> batchfilename.bat
echo > echo echo hello >> batchfilename.bat
echo > echo pause >> batchfilename.bat
it will input the code into the batch file and when you run batchfilename.bat you will get something like:
hello
press any key to continue . . .

Touch file to update the date/time of file? (Modified Date) (WindowsXP BatchScript)

What's a batch script command to touch on a file to update its date and time to the current date and time? (Modified Date)
For example, Joe Blow sends me a text document which he created months ago, when he emails me the document, I want to keep track of how old it is from the day I received it (not when he created it) so I want to update the file's date/time to the current date/time.
I have a batch script to automatically weed out files that haven't been edited within 90 days, so this is troublesome when I receive a particularly older file then all of a sudden it disappears.
And I need it via a batch script as I have hundreds of files to manage, and it's for archiving files.
I can't take all the credit, but I did look through my todo.txt to find it
Microsoft "touch" it's a KB article from like 5 years ago
The jist of it is you use copy /b MYFILENAME +,, where MYFILENAME is your file
This is an expansion on aflat's anwer.
1) Microsoft support provides an explanation and simple touch.bat script.
2) My custom touch.cmd, which expands on the MS script by including "touch /?" help text.
3) My custom midastouch.cmd, which provides several options including recursive operation and date operations.
As aflat wrote, the simple answer is:
copy /b FILENAME +,,
As you might expect, FILENAME can include relative or absolute path and wildcards like *.txt.
1. Microsoft1 support:
The following MS-DOS command updates the date and time stamps of a
file named "EXAMPLE" without altering the contents of the file. This
is similar to the TOUCH utility found in XENIX and in some third-party
MS-DOS toolkits.
COPY /B EXAMPLE +,,
The COPY command can concatenate a file onto an existing file when
used in the form:
COPY FILE1+FILE2
In this example, the contents of FILE2 are appended to FILE1, leaving FILE2 unchanged. When copying in this mode, the COPY command
switches to ASCII mode where the ^Z (0x01A) end-of-file marker is
honored.
Therefore, with the above command, the /b forces the COPY command into
binary mode, the filename is the file to be updated, the + (plus sign)
indicates that a file is to be appended, and the ,, (commas) are
placeholders for the remaining parameters (which are not included in
this example). Because the file to be appended is not specified, the
COPY command will append nothing and only update the time and date
stamps for the file.
The following batch file, TOUCH.BAT, can be used to automate the
process:
#echo off
if %1.==. goto end
if not exist %1 goto end
copy /b %1 +,, > nul
echo %1 touched!
:end
This batch file requires one parameter, the file to be "touched." If the
parameter is not supplied, line 2 will cause the batch file to
exit without doing anything. If the specified file does not exist,
line 3 will cause the batch file to exit also.
2. Touch.cmd
#echo off
:: -----------------------------------------
:: Process input parameter
:: -----------------------------------------
: Help requestes?
if "%1%"=="/?" goto help
if "%1%"=="?" goto help
if "%1%"=="" goto help
:: -----------------------------------------
:: Update Modified Date property to now
:: -----------------------------------------
if not exist %1% goto end
copy /b %1% +,, > nul
echo %1 touched!
goto end
:help
#echo off
echo :: --------------------------------------------------------------
echo :: Touch.cmd Help
echo :: --------------------------------------------------------------
echo.
echo Touch.cmd is batch script to update the Modified Date property
echo of teh specified file to the current
echo date and time.
echo.
echo Syntax: touch filename
echo where,
echo filename is the name of the name of the file to "touch."
echo filename may include a relative o full path.
echo filename may include wild cards like *.txt.
echo.
:end
3. MidasTouch.cmd
#echo off
:: -----------------------------------------
:: Find files older than specified date
:: -----------------------------------------
:: -----------------------------------------
:: Default Values
:: -----------------------------------------
set "default_path=%cd%"
set "default_err_log=%cd%\midastouch_err.log"
set /a default_date=-365
set "open_log=False"
set "recurse=True"
:: -----------------------------------------
:: Process input parameters
:: -----------------------------------------
: Help requestes?
if "%1%"=="/?" goto help
if "%1%"=="?" goto help
if /I "%1%"=="help" goto help
set "dir_in="
set "err_log="
set "dd="
:: Read in commandline arguements.
echo Arguements:
:arguement_loop
if "%1%"=="/p" (
echo Path: %2%
set dir_in=%2%
shift
goto loop_bottom)
if "%1%"=="/l" (
echo Error log: %2%
set err_log=%2%
shift
goto loop_bottom)
if "%1%"=="/-l" (
echo No error log. Output to console.
set err_log=CON
shift
goto loop_bottom)
if "%1%"=="/d" (
echo Date: %2%
set /a dd=%2%
shift
goto loop_bottom)
if "%1%"=="/o" (
echo Open log: True
set "open_log=True"
goto loop_bottom)
if "%1%"=="/-o" (
echo Open log: False
set "open_log=False"
goto loop_bottom)
if "%1%"=="/s" (
echo Recursive: True
set "recurse=True"
goto loop_bottom)
if "%1%"=="/-s" (
echo Recursive: False
set "recurse=False"
goto loop_bottom)
if not "%1%"=="" (
if "%dir_in%"=="" (
echo Path: %1%
set dir_in=%1%
goto loop_bottom)
if "%err_log%"=="" (
echo Error log: %1%
set err_log=%1%
goto loop_bottom)
if "%dd%"=="" (
echo Date: %1%
set /a dd=%1%
goto loop_bottom)
)
:loop_bottom
shift
if not "%1%"=="" goto arguement_loop
if "%dir_in%"=="" (
set dir_in=%default_path%)
if "%err_log%"=="" (
set err_log=%default_err_log%)
if "%dd%"=="" (
set /a dd=%default_date%)
:: -----------------------------------------
:: Execution
:: -----------------------------------------
:: Write header
set "header=Touch_dir.cmd Error Log"
if exist %err_log% (
del /q %err_log%)
#echo %header% >%err_log%
set cmd_str="cmd /c copy /b #path +,,"
:: Update Modified Date property to now
if /I "%recurse%"=="True" (
set cmd_str=forfiles /s /p %dir_in% /d %dd% /c %cmd_str%
) else (
set cmd_str=forfiles /p %dir_in% /d %dd% /c %cmd_str%
)
echo Command: %cmd_str% >>%err_log%
echo Errors: >>%err_log%
echo. >>%err_log%
echo Executing command: %cmd_str%
#echo Updating Modified Date of files older than date: %dd%.
#echo This may take a while. Please be patient...
#echo.
echo.
set cmd_str=%cmd_str% || #echo Failed to update: #path >>%err_log%"
%cmd_str%
:: Results
#echo Error log: %err_log%
if "%open_log%"=="True" (start %err_log%)
goto end
:help
#echo off
echo :: --------------------------------------------------------------
echo :: Touch_dir.cmd Help
echo :: --------------------------------------------------------------
echo.
echo Touch.cmd is batch script to recursively "touch" all files in a
echo folder to update their Modified Date property to the current
echo date and time.
echo.
echo Syntax: touch_dir /d directory /l err_log /m months
echo where,
echo /p path Path containing files with Modified
echo Date values to update to now.
echo (default = current directory).
echo /s (or /-s) Recursive (or not recursive) search
echo (default recursive is %recurse%).
echo /l err_log Error log: list of files not updated
echo (default err_log: midastouch_err.log).
echo /o (or /-o) Open (or do not open) error log after
echo execution (default open_log: %open_log%).
echo /d date Selects files with a last modified date greater
echo than or equal to (+), or less than or equal to
echo (-), the specified date using the
echo "MM/dd/yyyy" format; or selects files with a
echo last modified date greater than or equal to (+)
echo the current date plus "dd" days, or less than or
echo equal to (-) the current date minus "dd" days. A
echo valid "dd" number of days can be any number in
echo the range of 0 - 32768.
echo "+" is taken as default sign if not specified.
echo (default date is: %default_date%).
echo.
:end
Just to add that the same source provide a batch script.
#echo off
goto start
:usage
echo usage: TOUCH.BAT "MYFILENAME"
exit /b 0
:start
if %1.==. goto usage
if not exist %1 goto usage
copy /b %1 +,, > nul
echo %1 touched!
exit /b 0

Resources