English 中文(简体)
Batch 文档和USB动力信
原标题:Batch file and variable USB drive letters

I m试图创建备份目录,使Ausnis真实形象和备份维护自动化。

视I机器背后和(或)有多少装置连接和使用驱动信而定,USB驱动信的改动。

My batch resides in C: My batch will call ATI. ATI dumps an image onto C: The batch then looks for my external based on its volume serial number like so:

SET SN=30BC-F5A4
SET found=

0>NUL SET /P=Searching for external drive...
TIMEOUT 3 /NOBREAK >NUL

FOR %%N IN (D E F G H I J K L M O P Q R S T U V W X Y Z) DO (
IF defined found CALL :MOVE
VOL %%N: 2>NUL | FIND "%sn%" >NUL && CALL :MOVE %%N
)

ECHO  Fail^^!
TIMEOUT 3 /NOBREAK >NUL

ECHO.
ECHO Connect it now and cancel "Autoplay".
TIMEOUT 3 /NOBREAK >NUL

ECHO.
ECHO Press any key to try again...
PAUSE >NUL

CALL: EXTERNAL



:: ***MOVE BACKUP***

:MOVE

“科索沃”,这项工作只是罚款,但我现在需要的是大致如此的东西;

Find the correct external device based off of serial number. (As above) Grab the correct drive letter and turn it into a variable. Break out of the FOR IN DO loop when the drive letter is found and make it a variable. Use variable to check if a folder exists. If the folder doesn t exist, create it. If the folder does exist, check if MyBackup.tib exists within. If so, delete the file. CHDIR or somesuch back to where the batch resides, (C:) and MOVE the newly created backup into the folder on the external.

我花了10小时就该问题开展直接工作,我没有比我开始更接近找到正确的辛迪加/通曼。

PLEASE, can you help!? I ll give you a cookie, lol!

I m running Windows 7 Ultimate if that helps...

最佳回答

序号是六dec英的缩略号(thrown类的 d泥被thrown成千分母体)。

W 中等收入国家的体积,序列Number <>/code>可用于列出所有带有序列号的载体信,编号为 de。 页: 1 我在指挥线上用以下指挥器将你的太阳显赫转换成精细表:set /a 0x30BCF5A4

因此,以下指挥机构将对你对外驾驶的驾驶信(与殖民地)设定一个变数。

set SN=817690020
set "extDrive="
for /f %%D in ( wmic volume get driveLetter^, serialNumber ^| find "%sn%" ) do set extDrive=%%D
if not defined extDrive echo Error finding external drive & exit /b

我不理解你所谈论的翻番的名字。 我假定你有一个具有一定价值的变化。 我只字不提变的“夹”。

set folder=someFolderName
if not exist "%extDrive%\%folder%" mkdir "%extDrive%\%folder%"

你可以利用摩托车指挥把你新创建的后盾移至外部驱动力的夹子上,如果已经存在的话,自动推翻现有的任何备份。

move /y "c:MyBackup.tib" "%extDrive%\%folder%"
问题回答

你们可以要求“快车”来信:

Say some photos you need to back up are in directory ac on our drive, whose letter changes between computers. And, you want to back your photos up to your main drive, to directory xyz on the main drive (drive C:)

set /p Path="Enter the drive letter for your drive on this computer. No symbols, just the capital letter"
xcopy /e /v  %Path%:ac c:xyz

You could even ask for the path to back up to, like this...

set /p Path="Enter the drive letter for your removable drive on this computer. No symbols, just the capital letter."
set /p PathBackUp="Enter the path to where you want your data to be backed up on this computer. Start with a backslash."
set /p BackupDrive="Enter the drive letter for your data to be backed up to on this    computer. No symbols, just the capital letter."
xcopy /e /v  %Path%:ac %BackupDrive%:%PathBackUp%

set /p Path="Enter the drive letter for your removable drive on this computer. No symbols, just the capital letter."
set /p DataPath="Enter the path where your data to be backed up is. Start with a backslash, and don t include the drive letter.
set /p PathBackUp="Enter the path to where you want your data to be backed up on this computer. Start with a backslash, and don t include the drive letter."
set /p BackupDrive="Enter the drive letter for your data to be backed up to on this    computer. No symbols, just the capital letter."
xcopy /e /v  %Path%:%DataPath% %BackupDrive%:%PathBackUp%

我猜测这种说法不符合自动化的目的,但只是一种想法;这或许会有所帮助。

For more info about the xcopy authority and modifiers, see

For more info about the set direct, see

这只会发现与该系统有关的所有USB驱动器。

@echo off

for /F "usebackq tokens=1,2,3,4 " %%i in (`wmic logicaldisk get caption^,description^,drivetype 2^>NUL`) do (

if %%l equ 2 (
echo %%i is a USB drive.
        )
        )

我正在各地搜寻和尝试许多事情——这是最快和最简单的驾驶信转换指挥线选择

echo off

set /p Path="Enter the Drive Letter of the source File then press enter___"

set /p Pathde="Enter the Drive Letter of the Destination File then press enter___"

echo on

COPY %path%:UsersDellDesktop	est.txt %pathde%:	est.txt

我写了一幅小型C节目(lpath.exe),以解决改变可移动装置的驾驶信的问题。

目的是在相关的USB装置上建立一个目录(可以隐藏),或使用使用Windows探测器的驱动/拆名称。

The lpath programeck all available 软盘,只要有目录或软盘的名称,并退回目前用于批量文档的驱动信:

制作USB软盘上的目录:

mkdir f:USB-DISK1

2. 解决驱动信:

lpath USB-DISK1:myImagesHouse

<g:myImagesHouse, 而USB磁盘目前被分配到驱动信g:

举例说:

setlocal EnableDelayedExpansion
set input=USB-DISK1:exportsweekly
for /f "tokens=*" %%r in ( echo !input!^| lpath ) do set input=%%r
echo resolved directory is: !input!

更方便的方式是建立一个<>>>>。 连同灯塔。 外部方案

@echo off
rem
rem lset.cmd - set variable with resolved label path
rem
rem [00] 01.05.2019 CWa Initial Version
rem [02] 15.06.2019 CWa ++
rem
if not {%COMPUTERNAME%}=={!COMPUTERNAME!} echo %~n0-ERROR: use this function with  setlocal EnableDelayedExpansion  only & exit /b 7

rem USAGE: liblset variable "path"    - set variable with resolved label path

set __lset_path=%~2
if {!__lset_path!}=={} set %1=& exit /b
for /f "tokens=*" %%r in ( echo !__lset_path!^| "%~dp0lpath" ) do set %1=%%r
set __lset_path=

并且使用主要文字:

setlocal EnableDelayedExpansion
call lset input USB-DISK1:exportsweekly
echo resolved directory is: !input!

更详细的手册见:lpath - 扩展了含有标签的道路。

汇编的lpath.exetlset.cm可在WA2L/WinTools包装。

这种解决办法的不利之处在于,你至少需要一个额外的档案,与你的文字一起分发。





相关问题
complex batch replacement linux

I m trying to do some batch replacement for/with a fairly complex pattern So far I find the pattern as: find ( -name *.php -o -name *.html ) -exec grep -i -n hello {} + The string I want ...

How to split a string by spaces in a Windows batch file?

Suppose I have a string "AAA BBB CCC DDD EEE FFF". How can I split the string and retrieve the nth substring, in a batch file? The equivalent in C# would be "AAA BBB CCC DDD EEE FFF".Split()[n]

How to check which Operating System?

How can I check OS version in a batch file or through a vbs in an Windows 2k/2k3 environment ? You know ... Something like ... : "If winver Win2k then ... or if winver Win2k3 then ....