Make a relative path in batch file -
i have batch file wont know drive letter moving around alot.
for example: adobe files reside in: j:\files\new folder\usb\adob
the batch file executed from: j:\files\new folder\usb\usbstick
so tried code:
xcopy /s /y "%~dp0\..\..\usb\adob\*" "c:\program files\"
but not copy files. how can dynamic?
as drive letter seems relative part of scenario. believe should work better you, unless have misunderstood you.
xcopy /s /y "%~d0\files\new folder\usb\adob\*" "c:\program files\"
for more variables can use follow these steps:
cmd, type for /?
, read @ bottom.
%~i - expands %i removing surrounding quotes (") %~fi - expands %i qualified path name %~di - expands %i drive letter %~pi - expands %i path %~ni - expands %i file name %~xi - expands %i file extension %~si - expanded path contains short names %~ai - expands %i file attributes of file %~ti - expands %i date/time of file %~zi - expands %i size of file %~$path:i - searches directories listed in path environment variable , expands %i qualified name of first 1 found. if environment variable name not defined or file not found search, modifier expands empty string modifiers can combined compound results: %~dpi - expands %i drive letter , path %~nxi - expands %i file name , extension %~fsi - expands %i full path name short names %~dp$path:i - searches directories listed in path environment variable %i , expands drive letter , path of first 1 found. %~ftzai - expands %i dir output line in above examples %i , path can replaced other valid values. %~ syntax terminated valid variable name. picking upper case variable names %i makes more readable , avoids confusion modifiers, not case sensitive.
Comments
Post a Comment