I made a batch script that duplicates the file I specify when opening the file via the command line. This is the script:
setlocal
set file=%1
for /f %%i in ("%file%") do (
set drv=%%~di
set path=%%~pi
set ext=%%~xi
set name=%%~ni
)
copy "%1" "%drv%%path%%name% - Duplicate%ext%"
pause
And this is the command I use:
D:\> "duplicate.bat" D:\testfile.txt
This example works perfectly, but when I have a space in the file name, for example:
D:\> "duplicate.bat" D:\test file.txt
The batch file reads the file name as test
and the extension is left blank.
Hopefully this is possible :)
Ok, so thanks to madhawa priyashantha for helping with that problem, but now I realise that if I wan't to hide the cmd window that pops up when I run the script, I can use this solution here, but now the script fails to work on files with spaces again. Hopefully this is the last thing I need to do. :)