我是cmd批处理文件编码的新手。但是我想使用mklink / j创建firefox配置文件的联结链接。为此,我尝试了以下代码:
@echo off :Bismillahir Rahmanir Rahim @echo off
:: Run this script with elevation call :RequestAdminElevation "%~dpfs0" %* || goto:eof
set source = %USERPROFILE%\AppData\Roaming\Mozilla\Firefox\Profiles\*.default
set "target=c:\targe"
set "exclude=%temp%\exclude.txt" pause
(
rem exclude files/dires with these strings into full path
echo .txt
echo pipe.cmd
rem escaped backslash and initial and final quotes to avoid partial matches
echo "c:\\source\\directory\\something.txt"
rem exclude thisNot file/directory from source directory
echo "%source:\=\\%\\thisNot"
)> "%exclude%"
forfiles /P "%source%" /C "cmd /c (echo @path|findstr /i /v /g:"%exclude%" >nul) && if @isdir==TRUE (mklink /d \"%target%\\\"@file @path) else (mklink \"%target%\\\"@file @path)" del "%exclude%" > nul pause &goto:eof
但是当我运行此代码时,它显示无法找到指定的路径。这意味着它无法找到firfox配置文件夹。
我这次用其他网址尝试了。所以请给我一个解决方案。
答案 0 :(得分:0)
Forfiles不支持/ p参数中的文件,而是使用/ m,所以你应该使用
set "source=%USERPROFILE%\AppData\Roaming\Mozilla\Firefox\Profiles\"
和
forfiles /P "%source%" /M "*.default" /C ...