Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Windows 7中更改文件名并根据文件路径移动文件_Windows_File_Command Line_Scripting - Fatal编程技术网

在Windows 7中更改文件名并根据文件路径移动文件

在Windows 7中更改文件名并根据文件路径移动文件,windows,file,command-line,scripting,Windows,File,Command Line,Scripting,我有一堆图像文件分布在文件夹和子文件夹中。我想做的是将它们全部移动到一个文件夹中,并根据它们以前的路径重命名它们 例如,文件src/a/b/file1.png 应成为src/a_b_file1.png 在Linux中可能有一种聪明的方法可以做到这一点,但我目前使用的是Windows7机器 任何提示都很好,gui或命令行工具或一些脚本都不重要。Thanx.试试这个:然后检查记事本中的renfile.bat,看看它是否适合您。 如果需要,请添加更多文件类型 @echo off echo.@echo

我有一堆图像文件分布在文件夹和子文件夹中。我想做的是将它们全部移动到一个文件夹中,并根据它们以前的路径重命名它们

例如,文件src/a/b/file1.png

应成为src/a_b_file1.png

在Linux中可能有一种聪明的方法可以做到这一点,但我目前使用的是Windows7机器


任何提示都很好,gui或命令行工具或一些脚本都不重要。Thanx.

试试这个:然后检查记事本中的renfile.bat,看看它是否适合您。 如果需要,请添加更多文件类型

@echo off
echo.@echo off> renfile.bat
for /f "delims=" %%a in ('dir *.jpg *.png *.gif /b /s /a-d ') do call :next "%%a"
echo renfile.bat created
pause
goto :eof
:next
set "var=%~1"
call set "var=%%var:%cd%=%%"
set "var=%var:\=_%"
>>renfile.bat echo ren "%~1" "%var:~1%"
以及另一个批处理文件,用于在重命名所有文件后移动这些文件:

@echo off
md "c:\target folder\"
for /f "delims=" %%a in ('dir *.jpg *.png *.gif /b /s /a-d ') do (
move "%%a" "c:\target folder\"
)
您可以使用,该工具提供了大量重命名标记,例如

[DirName:X] Inserts the last directory name. eg. "c:\windows\notepad.exe" will give "windows" as result. If X is a numeric value that value will be used to select a folder name in the sequence from the right part of the path. [Dirname:3] for "c:\programs\games\new\mine sweeper\highscore\file.txt" will yield "new" [Dirname:4] for "c:\programs\games\new\mine sweeper\highscore\file.txt" will yield "games" [DirName:X]插入最后一个目录名。例如,“c:\windows\notepad.exe”将给出“windows”作为结果。 如果X是一个数值,则该值将用于从路径右侧的序列中选择文件夹名称。 [Dirname:3]对于“c:\programs\games\new\mine-sweeper\highscore\file.txt”将产生“new” [Dirname:4]对于“c:\programs\games\new\mine-sweeper\highscore\file.txt”将生成“games”
我最终使用了这个程序。乍一看,它易于安装和使用。

这是一个常见问题,请使用谷歌或搜索论坛。到目前为止你试过什么?我唯一真正试过的就是这个工具。然而,我搜索过谷歌,我能找到的东西似乎只支持在给定一些正则表达式(如上面的链接)的情况下重命名,但它们似乎不支持使用文件路径作为目标文件名的一部分。但也许有些事情我不明白。。。