命令提示符脚本重命名文件 [英] Command Prompt Scripting to rename files
问题描述
我获得了一些帮助,这些脚本可以编写批处理脚本来为foxidrive中的图章图像文件添加日期。但是,我弄乱了目录,它把该文件夹中的所有内容标记了日期。因此,现在我在每个文件名的末尾都有1000多个图像(.jpg)文件,带有此字符串--09-07-2014-09-07-2014-09-07-2014-09-07-2014-21 -07-2014-21-07-2014.jpg。
是否可以通过从给定文件夹中每个.jpg文件的这些文件名中删除上面的字符串来重命名它们?我打算在命令提示符下写这个
谢谢。
在文件夹中启动它,然后检查 renfiles.bat
以查看重命名命令是否正确,然后删除 .txt $ c $
@echo off
for(%.a)in(* .jpg)do(
echo %% a | repl ^。(。*)-2014年9月7日-2014年9月7日-2014年9月7日-2014年9月7日-2014年7月21日-21 -07-2014。* ren $& \q $ 1 %%〜xa\q ax>> renfiles.bat.txt
)
此文件使用名为 repl.bat
的帮助程序批处理文件(由dbenham提供)-下载地址:< a href = https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat rel = nofollow> https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat
将 repl.bat
放置在与批处理文件相同的文件夹中或路径中的文件夹中。 / p>
I got some help scripting a batch script to date stamp image files from foxidrive. However, i messed up on the directory and it date stamped everything in that folder. So right now i have 1000+ images (.jpg) files with this string on the end of each file name " - 09-07-2014 - 09-07-2014 - 09-07-2014 - 09-07-2014 - 21-07-2014 - 21-07-2014.jpg".
Is there a way to rename these by removing the string above from these file names on every .jpg file on a given folder? I am planning to write this on command prompt
Thanks.
Launch this in the folder and then examine renfiles.bat
to see if the rename commands look right, before removing the .txt
and running it.
@echo off
for %%a in (*.jpg) do (
echo "%%a"|repl "^.(.*) - 09-07-2014 - 09-07-2014 - 09-07-2014 - 09-07-2014 - 21-07-2014 - 21-07-2014.*" "ren $& \q$1%%~xa\q" ax >> renfiles.bat.txt
)
This uses a helper batch file called repl.bat
(by dbenham) - download from: https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat
Place repl.bat
in the same folder as the batch file or in a folder that is on the path.
这篇关于命令提示符脚本重命名文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!