发送到使用批处理文件
Send to using batch file
您好,我有一个主文件夹,其中包含两个文件夹 "active" 和 "confirmed"。
这两个文件夹下的子文件夹是相同的。我希望能够 select 我需要通过 windows 上下文菜单发送到已确认文件夹的文件,但我无法使用此代码。
for %%i in (%*) do (
REM Takt the path of each file and save it as source.
source=%%i
REM Change the word "active" in the path to "confirmed".
destnation=%%i:active=confirmed%
REM Move the file to the confirmed subtree.
move /-Y source destination
)
您需要使用SET
命令将字符串赋值给变量。您也不能使用 FOR
变量进行字符串替换。您还需要使用延迟扩展来引用代码块内的变量。
试试这个。
@echo off
for %%I in (%*) do (
REM Take the path of each file and save it as source.
set "destination=%%~dpI"
REM Change the word "active" in the path to "confirmed".
setlocal enabledelayedexpansion
set "destination=!destination:active=confirmed!"
REM Move the file to the confirmed subtree.
move /-Y "%%~I" "!destination!"
endlocal
)
您好,我有一个主文件夹,其中包含两个文件夹 "active" 和 "confirmed"。 这两个文件夹下的子文件夹是相同的。我希望能够 select 我需要通过 windows 上下文菜单发送到已确认文件夹的文件,但我无法使用此代码。
for %%i in (%*) do (
REM Takt the path of each file and save it as source.
source=%%i
REM Change the word "active" in the path to "confirmed".
destnation=%%i:active=confirmed%
REM Move the file to the confirmed subtree.
move /-Y source destination
)
您需要使用SET
命令将字符串赋值给变量。您也不能使用 FOR
变量进行字符串替换。您还需要使用延迟扩展来引用代码块内的变量。
试试这个。
@echo off
for %%I in (%*) do (
REM Take the path of each file and save it as source.
set "destination=%%~dpI"
REM Change the word "active" in the path to "confirmed".
setlocal enabledelayedexpansion
set "destination=!destination:active=confirmed!"
REM Move the file to the confirmed subtree.
move /-Y "%%~I" "!destination!"
endlocal
)