[操作疑難] 我諗 Window Batch 應該喺度問好啲

本帖最後由 ghostkcleung 於 2022-2-20 16:39 編輯

我有一大堆相片 File 在同一個 Path,
已經排好晒 YYYYMMDD_hhmmss.jpg
例如 20160627_164940.jpg

我想依日期 Create 一個 Folder,
例如 md 20160627
然後 Move File 入去。

唔想裝軟件,想用 Batch File 搞掂,Thanks。

留名學野, 我覺得用VBS 或者VBS 簡單好多

TOP

留名學野, 我覺得用VBS 或者VBS 簡單好多
bongbong3481 發表於 2022-2-20 16:04



諗到,用 dir 去 List 晒全部 file 出嚟,
save 去用 txt,用 Notepad ++ 去 Replace String,
然後 md。

辦法總比困難多。

TOP

dir /b *.jpg >mkdir.bat
use notepad++ to open mkdir.bat
remove the _xxx.jpg string by vertical editing (alt+mouse select+del)
insert mkdir in the beginning of each line , by vertical editing mouse keyboard combo(alt+select all lines at 0th position )
save dir.txt as mkdir.bat
附件: 您需要登錄才可以下載或查看附件。沒有帳號?註冊

TOP

用excel copy paste 整.bat仲方便, 唔使寫Program

TOP

用excel拉日期+create folder command
再用excel拉日期+move files command

TOP

本帖最後由 javacomhk 於 2022-2-20 22:13 編輯

use substring in batch file,  just remove echo in lines 5 to 6 to actually run it.
  1. @ECHO OFF
  2. setlocal enabledelayedexpansion
  3. for %%f in (.\*.jpg) do (
  4.   set x=%%f
  5.   echo if not exist "!x:~2,8!" mkdir !x:~2,8!
  6.   echo move %%f  !x:~2,8!\
  7. )
複製代碼

TOP



use substring in batch file,  just remove echo in lines 5 to 6 to actually run it.
javacomhk 發表於 2022-2-20 22:11

TOP