batch file - %~1 and %1 Automatically Removing Everything after the first Space -
so creating batch file store selected folder's path text file refer later on using batch script...
i created registry entries include right-click context menu folder triggers specific batch file.
basically when right click folder , click "send script" supposed copy whole path / location of right clicked folder.
to using following command:
set targetdir=%~1
i tried using %1and tried using following code delimiters
for /f "delims=;" %%a in ("%~1") ( @echo %%a ) the problem cmd automatically trimming after first space , since path copying, want keep spaces , path is
ex. if use command on folder such "c:/folder/subfolder" copyng done correctly if use command on folder such "c:/folder/sub folder" copying done incorrectly , give me "c:/folder/sub" removing rest found after first space detected.
registry entries
[hkey_classes_root\directory\shell\send-to-script] "muiverb"="send script" "subcommands"="sendscript" [hkey_local_machine\software\microsoft\windows\currentversion\explorer\commandstore\shell\sendscript] @="send script" [hkey_local_machine\software\microsoft\windows\currentversion\explorer\commandstore\shell\sendscript\command] @="c:\\scripts\\pathtotext.bat %1" thanks help
you should change registry key [...\sendscript\command] to
@="c:\\temp\\blob.bat \"%1\"" and in batch should use
rem disabledelayedexpansion preserve "!" in path names setlocal disabledelayedexpansion set "targetdir=%~1" setlocal enabledelayedexpansion ( echo target !targetdir! ) > c:\scripts\target.log if "reseverdfolder" == "!targetdir!" echo folder reserved
Comments
Post a Comment