So I have a bat file that I wrote, and I am having issues with setting variables that contain an & in the file path.
Right now this works, but I can't use the %SOURCE% or %DEST% variables in the copy command. I get an error. Hence the reason I have the full path written out in the copy command.
#echo off
echo Backing Up Build Files ^& Templates
echo.
:: do a dump of repo
echo Creating Dump File
svnadmin dump "Z:\Subversion\Build Files "^&" Templates" > "Z:\Subversion\Build Files "^&" Templates_repository-backup.dmp"
:: copy dump file to backup location
set YEAR=%date:~10,4%
set MONTH=%date:~4,2%
set DAY=%date:~7,2%
set THE_DATE=%MONTH%_%DAY%_%YEAR%
set SPACE_CHECK=%time:~0,1%
if "%SPACE_CHECK%"==" " goto handlehourspace
set HOURS=%time:~0,2%
goto hourdone
:handlehourspace
set HOURS=0%time:~1,1%
:hourdone
set MINUTES=%time:~3,2%
set SECONDS=%time:~6,2%
set THE_TIME=%HOURS%_%MINUTES%_%SECONDS%
set SOURCE="Z:\Subversion\Build Files "^&" Templates_repository-backup.dmp"
set DEST="K:\IETM_Repo_Backup\Build Files "^&" Templates\Build Files "^&" Templates_repository-backup.dmp"_%THE_DATE%_%THE_TIME%
echo Copying Dump File
copy /Z "Z:\Subversion\Build Files "^&" Templates_repository-backup.dmp" "K:\IETM_Repo_Backup\Build Files "^&" Templates\Build Files "^&" Templates_repository-backup.dmp"_%THE_DATE%_%THE_TIME%
echo Deleting Original Dump File
del "Z:\Subversion\Build Files "^&" Templates_repository-backup.dmp"
use this syntax: set "var=value" to be able to use special chars in a value:
set "x=this&that"
echo "%x%"
REM create a file:
break>"%x%"
dir this*
REM remove the file:
del "%x%"
With your style set DEST="K:\...." the quotes are part of the content. With the extended SET-syntax set "DEST=K:\...." they escape the string but aren't part of the string.
In the most cases you should use the extended syntax
set "SOURCE=Z:\Subversion\Build Files & Templates_repository-backup.dmp"
set "DEST=K:\IETM_Repo_Backup\Build Files & Templates\Build Files & Templates_repository-backup.dmp_%THE_DATE%_%THE_TIME%"
copy /Z "%SOURCE%" "%DEST%"
In the copy "%SOURCE%" ... line the quotes are necessary to escape again the ampersands and spaces.
To have a locale independent way to format the date/time I suggest using WMI
and the backup of the dump file stays better usable when the extension remains the last part of the file name, not the date/time stamp.
#echo off
echo Backing Up Build Files ^& Templates
echo.
:: get datetime string of the format yyyyMMddhhnnss.
for /f "tokens=1-3 delims=.+-" %%A in (
'wmic os get LocalDateTime^|findstr ^^[0-9]'
) do Set _DT=%%A
set THE_DATE=%_DT:~4,2%_%_DT:~6,2%_%_DT:~0,4%
set THE_TIME=%_DT:~8,2%_%_DT:~10,2%_%_DT:~12,2%
:: do a dump of repo
echo Creating Dump File
set "BFT=Build Files & Templates"
set "svnBFT=Z:\Subversion\%BFT%"
set "svnSRC=%svnBFT%_repository-backup.dmp"
svnadmin dump "%svnBFT%" > "%svnSRC%"
:: copy dump file to backup location
echo Copying Dump File
set "DEST=K:\IETM_Repo_Backup\%BFT%\%BFT%_repository-backup_%THE_DATE%_%THE_TIME%.dmp"
copy /Z "%svnSRC%" "%Dest%"
echo Deleting Original Dump File
del "%svnSRC%"
Related
I have two folders CopyFrom and CopyTo where CopyFrom has 100 text files named as 1.txt…100.txt and in CopyTo folder I have 100 folders as F1…F100. Now, I want to copy one file from CopyFrom folder to one folder in CopyTo so that F1 will contain 1.txt, F2 will contain 2.txt,…, F100 will contain 100.txt file.
I know to copy all folders I can use something like For /d %%a in (C:\Users\me\Desktop\ShortCuts\*) do xcopy "C:\Users\me\Desktop\Time.xls" "%%a", but I could not find a way to copy different files to different folders.
I can echo all the files (For %%a in (C:\Users\me\Desktop\ShortCuts\*) Echo "%%a") in the CopyFrom folder and also can Echo all the folders in CopyTo folder but could not figure out to working with both to get what I am looking for.
#echo off
setlocal enableextensions disabledelayedexpansion
rem Configure paths
set "copyFrom=c:\somewhere"
set "copyTo=c:\anotherPlace"
rem Generate two lists, one with files and one with folders
dir /b /a-d "%copyFrom%\*" > "%temp%\copyFromFiles.txt"
dir /b /ad "%copyTo%\*" > "%temp%\copyToFolders.txt"
rem Assign each list as input to two streams and start processing
9< "%temp%\copyFromFiles.txt" 8< "%temp%\copyToFolders.txt" (
call :matchFromWithTo
)
rem Remove generated lists
del "%temp%\copyFromFiles.txt"
del "%temp%\copyToFolders.txt"
rem End
goto :eof
:matchFromWithTo
rem Read file from stream 9 and leave if nothing read
<&9 set /p "file=" || goto :eof
rem Read folder from stream 8 and leave if nothing read
<&8 set /p "folder=" || goto :eof
rem Do the copy (debug: we will only echo the command)
echo copy "%copyFrom%\%file%" "%copyTo%\%folder%"
rem Keep reading until all files or folders are processed
goto :matchFromWithTo
Supposing the source location contains the files 1.txt to 100.txt only and the target location already contains all the F1 to F100 directories, the following code snippet might work for you:
#echo off
setlocal EnableExtensions DisableDelayedExpansion
rem // Define constants here:
set "Pattern=*.txt"
set "CopyFrom=."
set "CopyTo=D:\Target"
for %%F in ("%CopyFrom%\%Pattern%") do (
ECHO copy "%%~F" "%CopyTo%\F%%~nF\"
)
endlocal
exit /B
There is no enumeration of the target location done, the copy destination is simply derived from the source file name.
After having tested the script, remove the upper-case ECHO command to actually copy files!
I have a folder that gets a new file added everyday to the folder with the same file name but incremental extension such as .001, .002, .003, etc. However, if there's no file within the folder it starts at .001 again.
The problem is they are all named the same and if I move them to another folder to archive them it would just overwrite the same file over and over again. I could create a folder each day with the date with only one file in it, but that seems a bit redundant.
Is there a way to look at the create date of each file and rename it to the create date?
I've gotten this far, but it looks like for this situation I have to use a static file name, how to loop through the entire directory?
SET filename = C:\test.001
FOR %%f IN (%filename%) DO SET filedatetime=%%~tf
rename c:\test.001 C:\test_%filedatetime%.txt
move C:\*.txt C:\archive\
this provides the correct sort order:
#echo off &setlocal disableDelayedExpansion
set "startfolder=%userprofile%\test"
cd /d "%startfolder%"
for %%a in (*) do (
for /f "delims=." %%b in ('wmic datafile where "name='%startfolder:\=\\%\\%%~a'" get lastmodified^|find "."') do (
echo(ren "%startfolder%\%%~a" "%%~b.txt"
)
)
Remove echo to get it working.
#ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
SET "targetdir=c:\sourcedir"
SET "destdir=c:\destdir"
PUSHD "%targetdir%"
FOR %%a IN (*.*) DO (
SET "timestamp=%%~ta"
SET "timestamp=!timestamp:/=_!
SET "timestamp=!timestamp::=_!
SET "timestamp=!timestamp:.=_!
SET "timestamp=!timestamp:,=_!
SET "timestamp=!timestamp: =_!
ECHO MOVE "%%a" "%destdir%\%%~na.!timestamp!"
)
GOTO :EOF
This should work with any file in the nominated target directory where the name does not include ! or ^.
The required MOVE commands are merely ECHOed for testing purposes. After you've verified that the commands are correct, change ECHO MOVE to MOVE to actually move the files. Append >nul to suppress report messages (eg. 1 file moved)
The gymnastics around timestamp are intende to replace /: with _ since these are illegal filename characters. Space., are similarly replaced - they're legal but often painful.
If you want the destination filename to be name.003.timestamp, remove the ~na from the destination name.
Try like this :
SET $path=The_path_who_contain_the_FILES
FOR /F "DELIMS=" %%f IN ('dir "%$path%" /a-d/b') DO (
SET filedatetime=%%~tf
move "%%~dpnxf" "C:\archive\test_%filedatetime%.txt")
I is it possible using the script below to delete the local files if they no longer exist on the remote directory? Currently this downloads all new files but wont delete files that no longer exist on the ftp server?
#Echo Off
REM -- Define File Filter, i.e. files with extension .txt
set FindStrArgs=/x "..*\...*"
REM -- Extract Ftp Script to create List of Files
Set "FtpCommand=ls"
Call:extractFileSection "[Ftp Script 1]" "-">"%temp%\%~n0.ftp"
Rem Notepad "%temp%\%~n0.ftp"
REM -- Execute Ftp Script, collect File Names
Set "FileList="
For /F "Delims=" %%A In ('"Ftp -v -i -s:"%temp%\%~n0.ftp"|Findstr %FindStrArgs%"') Do (
Call Set "FileList=%%FileList%% "%%A""
)
REM -- Extract Ftp Script to download files that don't exist in local folder
Set "FtpCommand=mget"
For %%A In (%FileList%) Do If Not Exist "%%~A" Call Set "FtpCommand=%%FtpCommand%% "%%~A""
Call:extractFileSection "[Ftp Script 1]" "-">"%temp%\%~n0.ftp"
Rem Notepad "%temp%\%~n0.ftp"
For %%A In (%FtpCommand%) Do Echo.%%A
REM -- Execute Ftp Script, download files
ftp -i -s:"%temp%\%~n0.ftp"
Del "%temp%\%~n0.ftp"
GOTO:EOF
:extractFileSection StartMark EndMark FileName -- extract a section of file that is defined by a start and end mark
:: -- [IN] StartMark - start mark, use '...:S' mark to allow variable substitution
:: -- [IN,OPT] EndMark - optional end mark, default is first empty line
:: -- [IN,OPT] FileName - optional source file, default is THIS file
:$created 20080219 :$changed 20100205 :$categories ReadFile
:$source http://www.dostips.com
SETLOCAL Disabledelayedexpansion
set "bmk=%~1"
set "emk=%~2"
set "src=%~3"
set "bExtr="
set "bSubs="
if "%src%"=="" set src=%~f0& rem if no source file then assume THIS file
for /f "tokens=1,* delims=]" %%A in ('find /n /v "" "%src%"') do (
if /i "%%B"=="%emk%" set "bExtr="&set "bSubs="
if defined bExtr if defined bSubs (call echo.%%B) ELSE (echo.%%B)
if /i "%%B"=="%bmk%" set "bExtr=Y"
if /i "%%B"=="%bmk%:S" set "bExtr=Y"&set "bSubs=Y"
)
EXIT /b
If possible, use an ftp client like lftp. It will give you options to mirror two ftp locations in one line of code (see mirror option). Also check out the flags:
--only-newer
--parallel=10
--delete
I have below script, in this there are two path one is Target path (only one) and another source path (variables).
About below script function: I'll run this once in a month and it'll go the souce path (10 path) and copy lates file then copy&rename to target path (common for all the files).
note : file which is copyed form the respacted source should be rename as per script like:
file from "F:\Financial\Data\Reports\AccruntPnLMTD" should be rename as "PNL.csv"
#echo off
setlocal
set DateFolder=04.2013
set TargetFolder=F:\Financial\Data\%DateFolder%\Final Reports
:: copy the newest file from AccruntPnLMTD and rename it to PNL.csv
call :copyAndRename "F:\Financial\Data\Reports\AccruntPnLMTD" "%TargetFolder%\PNL.csv"
:: copy the newest file from AccountPnlMTD and rename it to AC.csv
call :copyAndRename "F:\Financial\Data\Reports\AccountPnlMTD" "%TargetFolder%\AC.csv"
:: copy the newest file from ExpensesMTD and rename it to EXPMTD.csv
call :copyAndRename "F:\Financial\Data\Reports\ExpensesMTD" "%TargetFolder%\EXPMTD.csv"
:: copy the newest file from ExpensesYTD and rename it to EXPYTD.csv
call :copyAndRename "F:\Financial\Data\Reports\ExpensesYTD" "%TargetFolder%\EXPYTD.csv"
:: copy the newest file from AccrualPnLYTD and rename it to PNLYTD.csv
call :copyAndRename "F:\Financial\Data\Reports\AccrualPnLYTD" "%TargetFolder%\PNLYTD.csv"
:: copy the newest file from AccountYTD and rename it to ACYTD.csv
call :copyAndRename "F:\Financial\Data\Reports\AccountYTD" "%TargetFolder%\ACYTD.csv"
:: copy the newest file from BalanceMTD and rename it to BSMTD.csv
call :copyAndRename "F:\Financial\Data\Reports\BalanceMTD" "%TargetFolder%\BSMTD.csv"
:: copy the newest file from BalanceYTD and rename it to BSYTD.csv
call :copyAndRename "F:\Financial\Data\Reports\BalanceYTD" "%TargetFolder%\BSYTD.csv"
:: copy the newest file from FinancialStmtMTD and rename it to FSMTD.csv
call :copyAndRename "F:\Financial\Data\Reports\FinancialStmtMTD" "%TargetFolder%\FSMTD.csv"
:: copy the newest file from FinancialStmtYTD and rename it to FSYTD.csv
call :copyAndRename "F:\Financial\Data\Reports\FinancialStmtYTD" "%TargetFolder%\FSYTD.csv"
:: Done
goto :eof
:copyAndRename
set SourceFolder=%~1
set TargetFile=%~2
:: Find the newest file in the source folder
for /f "tokens=*" %%F in ('dir /b /od /a-d "%SourceFolder%"') do set "NewestFile=%%F"
:: copy and rename it to the target
copy "%SourceFolder%\%NewestFile%" "%TargetFile%"
:: Done with this subroutine
goto :eof
I want's to give both path after run the script (popup should ask for the path)
Excuse me. Your question is not clear. I assume that you want to copy and rename the 10 given files but not with the fixed paths given in the program, but with variable paths given when the program run. If this is correct, the program must get first the Target path (only one) and then the source path for each one of the files.
The Batch file below is a preliminary version that achieve previous process. If this solution is what you want, then the "browsing popup" part for the paths may be added instead of the simple "set /P folder=Enter folder:" commands. Or perhaps this version is enough for you?
EDIT: I modified the solution below in order to include these new requests:
I have variable target path for diffrent clients like for client a
path wil be F:\Financial\ClientA\Data\%DateFolder%\Final Reports..&
for client B "F:\Financial\ClientB\Data\%DateFolder%\Final Reports"
same goes in source path like Client A path
"F:\Financial\Data\Reports\Client A\AccruntPnLMTD ; for client B Path
will be F:\Financial\Data\Reports\Client B\AccruntPnLMTD..file folder
names (AccruntPnLMTD,AccruntPnLMTD..etc) will reman same for each
clients
LAST EDIT: The Batch file below has been modified for the last time in accordance with the last paragraph in this answer: Browse the existent folders in the disk and pick one.
#if (#CodeSection == #Batch) #then
#echo off
setlocal
rem Activate the browsing pop-up and ask for TargetFolder
for /F "delims=" %%a in ('CScript //nologo //E:JScript "%~F0" "Select the Target folder"') do (
set TargetFolder=%%a
)
rem Activate the browsing pop-up and ask for SourceFolder
for /F "delims=" %%a in ('CScript //nologo //E:JScript "%~F0" "Select the Source folder"') do (
set ClientSourceFolder=%%a
)
rem Process the list of "sourceFolder=fileName" pairs
for %%a in ("AccruntPnLMTD=PNL" "AccountPnlMTD=AC" "ExpensesMTD=EXPMTD" "ExpensesYTD=EXPYTD" "AccrualPnLYTD=PNLYTD"
"AccountYTD=ACYTD" "BalanceMTD=BSMTD" "BalanceYTD=BSYTD" "FinancialStmtMTD=FSMTD" "FinancialStmtYTD=FSYTD"
) do (
rem copy the newest file from sourceFolder and rename it to fileName.csv
for /F "tokens=1,2 delims==" %%b in (%%a) do (
call :copyAndRename "%%b" "%%c"
)
)
:: Done
goto :eof
:copyAndRename
set SourceFolder=%ClientSourceFolder%\%~1
set TargetFile=%TargetFolder%\%~2.csv
:: Find the newest file in the source folder
for /f "tokens=*" %%F in ('dir /b /od /a-d "%SourceFolder%"') do set
"NewestFile=%%F"
:: copy and rename it to the target
copy "%SourceFolder%\%NewestFile%" "%TargetFile%"
:: Done with this subroutine
goto :eof
#end
// JScript section
// Creates a dialog box that enables the user to select a folder.
// http://msdn.microsoft.com/en-us/library/windows/desktop/bb774065(v=vs.85).aspx
var shl = new ActiveXObject("Shell.Application");
var folder = shl.BrowseForFolder(0, WScript.Arguments(0), 0, 0);
WScript.Stdout.WriteLine(folder ? folder.self.path : "");
In this new solution you may SELECT the desired client via the parameter of the Batch file. For example, if the Batch file is called example.bat, use this command for ClientA:
example.bat ClientA
You must note that BROWSING FOR A FOLDER is an interactive operation that present a pop-up window with all existent folders and allows you to choose one of them.
EDIT: Some explanations added
It seems that there is a confusion here. In your question you show as examples of target and source folders these ones:
set TargetFolder=F:\Financial\Data\%DateFolder%\Final Reports
:: copy the newest file from AccruntPnLMTD and rename it to PNL.csv
call :copyAndRename "F:\Financial\Data\Reports\AccruntPnLMTD"
However, in posterior comments you said:
I have variable target path for diffrent clients like for client a path wil be
F:\Financial\ClientA\Data\%DateFolder%\Final Reports..& for client B
F:\Financial\ClientB\Data\%DateFolder%\Final Reports
same goes in source path like Client A path
F:\Financial\Data\Reports\Client A\AccruntPnLMTD ; for client B Path will be
F:\Financial\Data\Reports\Client B\AccruntPnLMTD..
file folder names (AccruntPnLMTD,AccruntPnLMTD..etc) will reman same for each clients
You must realize that two previous forms are entirely different: in the first one the folder path is constant, but in the second one the folder path must be changed for each client. A Batch file solution is always designed with fixed requirements. This point is not clear in your answer nor in your comments, so I assumed certain details in order to write a Batch solution. I think there are two ways to solve this problem, depending of what the problem is:
1- Select the appropriate folders for each client: in this case I assumed that path folders have this form:
Target Folder is formed by "F:\Financial\" followed by a variable part that select each client, followed by "\Data\%DateFolder%\Final Reports".
Source path is formed by "F:\Financial\Data\Reports\" followed by a variable part that select each client, followed by each one of the 10 different folders (AccruntPnLMTD,AccruntPnLMTD..etc).
If this is the problem, then my solution above solve it. You just need to place the desired folder name as parameter of the Batch file. For example, if the name of the folder for client a is "ClientA", execute this command:
nameOfTheBatchFile ClientA
If the name of the folder for client B is "ClientB", execute this command:
nameOfTheBatchFile ClientB
If the name of the folder have spaces, enclose it in quotes; for example, for "Any other client" execute this command:
nameOfTheBatchFile "Any other client"
However, your posterior comments and insistence on using terms like "browsing popup", "asking for the path", etc. makes me think that the previously explained problem is not the one you want to solve. There is another possibility:
2- Browse the existent folders in the disk and pick one: in this case when the program run it present a "browsing popup" window that give access to all folders in the disk and allows you to select anyone of them. Note that the browsing window can NOT restrict the browse for any particular name format; if you want that the selected folder have certain characteristics, like the data placed after "Data\" part be today's date in "MM.YYYY" format or any other restriction, this checking must be done after the user choose a folder, so the program will indicate that the selected folder was invalid and popup the browsing window again.
I encourage you to clearly explain your requirements. Please, modify your original question so anyone can understand the problem after read it and don't require to review all the comments in all answers.
This is untested - it merges your code with the popup routine and asks for the source folder once, where all the folders are expected to be.
#echo off
setlocal
set DateFolder=04.2013
:: set the source and target folders
call :getpath
set "TargetFolder=%TargetFolder%\%DateFolder%\Final Reports"
:: copy the newest file from AccruntPnLMTD and rename it to PNL.csv
call :copyAndRename "AccruntPnLMTD" "%TargetFolder%\PNL.csv"
:: copy the newest file from AccountPnlMTD and rename it to AC.csv
call :copyAndRename "AccountPnlMTD" "%TargetFolder%\AC.csv"
:: copy the newest file from ExpensesMTD and rename it to EXPMTD.csv
call :copyAndRename "ExpensesMTD" "%TargetFolder%\EXPMTD.csv"
:: copy the newest file from ExpensesYTD and rename it to EXPYTD.csv
call :copyAndRename "ExpensesYTD" "%TargetFolder%\EXPYTD.csv"
:: copy the newest file from AccrualPnLYTD and rename it to PNLYTD.csv
call :copyAndRename "AccrualPnLYTD" "%TargetFolder%\PNLYTD.csv"
:: copy the newest file from AccountYTD and rename it to ACYTD.csv
call :copyAndRename "AccountYTD" "%TargetFolder%\ACYTD.csv"
:: copy the newest file from BalanceMTD and rename it to BSMTD.csv
call :copyAndRename "BalanceMTD" "%TargetFolder%\BSMTD.csv"
:: copy the newest file from BalanceYTD and rename it to BSYTD.csv
call :copyAndRename "BalanceYTD" "%TargetFolder%\BSYTD.csv"
:: copy the newest file from FinancialStmtMTD and rename it to FSMTD.csv
call :copyAndRename "FinancialStmtMTD" "%TargetFolder%\FSMTD.csv"
:: copy the newest file from FinancialStmtYTD and rename it to FSYTD.csv
call :copyAndRename "FinancialStmtYTD" "%TargetFolder%\FSYTD.csv"
:: Done
goto :eof
:copyAndRename
set "FileFolder=%SourceFolder%\%~1"
set "TargetFile=%~2"
echo copying "%FileFolder%"
:: Find the newest file in the source folder
for /f "tokens=*" %%F in ('dir /b /od /a-d "%FileFolder%"') do set "NewestFile=%%F"
:: copy and rename it to the target
copy "%FileFolder%\%NewestFile%" "%TargetFile%" >nul
:: Done with this subroutine
goto :eof
:getsourcepath
Call :BrowseFolder "Choose Source folder" "C:\Program Files\"
Set "SourceFolder=%Result%"
Call :BrowseFolder "Choose Target folder" "C:\Users\"
Set TargetFolder=%Result%
REM echo %SourceFolder%
REM echo %TargetFolder%
:: Done
goto :eof
:BrowseFolder
set Result=
set input="%~1" & set default="%~2"
:: Temporary files
set vbs=%temp%\_.vbs
set tmp=%temp%\_.cmd
:: Build VBScript file
findstr "'%skip%VBS" "%~f0" > "%vbs%"
:: Run the script with WSH and set Path as Env variable %Result%
for /f "delims=" %%a in ('cscript /nologo "%vbs%" ') do set "Result=%%a"
DEL %VBS%
set vbs= & set tmp= & set input= & set default=
goto :EOF
set WshShell=WScript.CreateObject("WScript.Shell") 'VBS
set shell=WScript.CreateObject("Shell.Application") 'VBS
sInput=WshShell.ExpandEnvironmentStrings("%input%") 'VBS
sDefault=WshShell.ExpandEnvironmentStrings("%default%") 'VBS
sInput = Replace(sInput, chr(34), "") 'VBS
sDefault = replace(sDefault,chr(34),"") 'VBS
set folder=shell.BrowseForFolder(0,sInput,0,sDefault) 'VBS
if typename(folder)="Nothing" Then 'VBS
wscript.echo "set Result=Dialog Cancelled" 'VBS
WScript.Quit(1) 'VBS
end if 'VBS
set folderItems=folder.Items() 'VBS
set folderItem=folderItems.Item() 'VBS
pathname=folderItem.Path 'VBS
wscript.echo pathname 'VBS
I have made a batch script to move and rename a file by dragging and dropping a file onto the script. This will assume the source of the file is unknown, but the target directory is.
My solution was to CD to the target directory, reverse the source file name, use the for command with backslash as a delim to have the file name, then reverse it again then finally rename it.
Just wondering if there was an easier solution.
#echo off
echo %1
set newSong=%1
cd "C:\Riot Games\League of Legends\RADS\projects\lol_air_client\releases\0.0.0.230\deploy\assets\sounds\ambient"
if not exist LoginScreenIntro.mp3.bak rename LoginScreenIntro.mp3 LoginScreenIntro.mp3.bak
del LoginScreenIntro.mp3
copy %newSong% "%CD%"
Call :ReverseString %newSong%
Set ReverseString.Result="%ReverseString.Result%"
for /f "tokens=1 delims=\" %%a in (%ReverseString.Result%) do set reversesong=%%a
Call :ReverseString "%reversesong%"
set newSong=%ReverseString.Result%
rename "%newSong%" LoginScreenIntro.mp3
pause
:ReverseString
Set ReverseString.TempVar=%~1
Set ReverseString.Result=
:ReverseString.Loop
Set ReverseString.Result=%ReverseString.TempVar:~0,1%%ReverseString.Result%
Set ReverseString.TempVar=%ReverseString.TempVar:~1,999%
if not "%ReverseString.TempVar%"=="" goto ReverseString.Loop
Goto :Eof
How about this?
ren %1 NewName.ext
move %~dp1\NewName.ext NewDir
Heh, all I needed was
set newsong=%~n1%~x1