Board logo

標題: [操作疑難] 我諗 Window Batch 應該喺度問好啲 [打印本頁]

作者: ghostkcleung    時間: 2022-2-20 16:02     標題: 我諗 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。
作者: bongbong3481    時間: 2022-2-20 16:04

留名學野, 我覺得用VBS 或者VBS 簡單好多
作者: ghostkcleung    時間: 2022-2-20 16:13

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



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

辦法總比困難多。
作者: 杜龍    時間: 2022-2-20 17:13

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
[attach]2307556[/attach]
作者: 杜龍    時間: 2022-2-20 17:15

用excel copy paste 整.bat仲方便, 唔使寫Program
作者: chilun    時間: 2022-2-20 18:16

用excel拉日期+create folder command
再用excel拉日期+move files command
作者: javacomhk    時間: 2022-2-20 22:11

本帖最後由 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. )
複製代碼

作者: ghostkcleung    時間: 2022-2-21 02:01



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





歡迎光臨 電腦領域 HKEPC Hardware (https://h2.hkepc.com/forum/) Powered by Discuz! 7.2