对JPG文件替换的文件夹中的文本 [英] replacing text on jpg files in a folder
问题描述
我有一个具有从相机和JPG连续拍摄JPG图片文件夹都是这种格式。
1UYK08HJ_20140403165858071_SYPTE1-PC.jpg
1YK0BHJX_20140403165902791_SYPTE1-PC.jpg
1YK08HJX_20140403165959270_SYPTE1-PC.jpg
IDYKDBH_20140403170236634_SYPTE1-PC.jpg
我试图取代从SYPTE1-PC谢菲尔德文字我运行此脚本它完美地运行,第一次,但是当我尝试再次运行同一个脚本它不会对其他新创建的图像工作。我已经使用名为repl.bat第三方辅助批处理文件。 https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat
关闭@echo
DIR * .JPG / B /广告|找到/ I / V%〜NX0|找到/ I / Vrepl.bat|(?* _)REPL(....)(..)( ..)(..)(..)(..)(......)*(\\ .. *)仁\\ q $&放大器; \\ q \\ q $ 1SHEFFIELD_ $ 2_ $ 3_ $ 4- $ 5_ $ 6_ $ 7_ $ $ 8 9 \\ qXA>C:\\用户\\ IT管理员\\桌面\\出口\\ renfiles.bat
试试这个:
关闭@echo和放大器; CLS
SETLOCAL EnableDelayedExpansion
对于一个%%的(* .JPG)做(
设置$文件=%%一个
仁%%一个$文件:!SYPTE1-PC = SHEFFIELD
回声文件[%%一]完成)
:编辑
有关更多的选项,你可以这样做:
关闭@echo和放大器; CLS
SETLOCAL EnableDelayedExpansion
对于一个%%的(* .JPG)做(
设置$文件=%%一个
设置$文件=$文件:SYPTE1-PC = SHEFFIELD!
设置$文件=$文件:!SYPTE = SHEFFIELD
仁%%一个!$文件!
回声文件[%%一]完成)
编辑2
的方法来分离:20140403165858071在2014_04_03_16_58_58_071
关闭@echo和放大器; CLS
SETLOCAL EnableDelayedExpansion
FOR / F令牌= 1-4 delims = _。 %%一个在('DIR / B / A-D * .JPG')做(
呼应%%一个%% b %%Çð%%
设置$字符= %% b
设置$ CharF = $字符:!〜0,4 _ $字符:!〜4,2 _ $字符:!!!〜6,2 _ $字符:!〜8,2 _ $字符:!〜10 !,2 _ $字符:12,2〜_ $字符:!〜14!
回音!$ CharF!
暂停)
您可以再调整自己的 REN
与 %%一_!$ CharF!_ %%ç_ %%ð
或者你想要的方式。
I have folder which has jpg images continuously taken from a camera and the jpg are in this format.
1UYK08HJ_20140403165858071_SYPTE1-PC.jpg
1YK0BHJX_20140403165902791_SYPTE1-PC.jpg
1YK08HJX_20140403165959270_SYPTE1-PC.jpg
IDYKDBH_20140403170236634_SYPTE1-PC.jpg
I am trying to replace the text from SYPTE1-PC to SHEFFIELD I am running this script it runs first time perfectly but when i try to run the same script again it does not work on other newly created images. I have used a third party helper batch file called repl.bat. https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat
@echo off
dir *.jpg /b /a-d |find /i /v "%~nx0" |find /i /v "repl.bat" |repl "(.*?_)(....)(..)(..)(..)(..)(..)(...).*(\..*)" "ren \q$&\q \q$1SHEFFIELD_$2_$3_$4-$5_$6_$7_$8$9\q" xa >"C:\Users\IT-Administrator\Desktop\export\renfiles.bat"
Try this :
@echo off&cls
setlocal EnableDelayedExpansion
for %%a in (*.JPG) do (
set $file="%%a"
ren "%%a" "!$file:SYPTE1-PC=SHEFFIELD!"
echo File [%%a] Done)
:EDIT
For more option you can do like this :
@echo off&cls
setlocal EnableDelayedExpansion
for %%a in (*.JPG) do (
set $file="%%a"
set $file="!$file:SYPTE1-PC=SHEFFIELD!"
set $file="!$file:SYPTE=SHEFFIELD!"
ren "%%a" "!$file!"
echo File [%%a] Done)
EDIT 2
The method to separate : 20140403165858071 in 2014_04_03_16_58_58_071
@echo off&cls
setlocal EnableDelayedExpansion
for /f "tokens=1-4 delims=_." %%a in ('dir /b/a-d *.JPG') do (
echo %%a %%b %%c %%d
set $Char=%%b
set $CharF=!$Char:~0,4!_!$Char:~4,2!_!$Char:~6,2!_!$Char:~8,2!_!$Char:~10,2!_!$Char:~12,2!_!$Char:~14!
echo !$CharF!
pause)
You can then adjust yourself the REN
with %%a_!$CharF!_%%c_%%d
or the way you want it
这篇关于对JPG文件替换的文件夹中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!