0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

forfilesを使用した、数字名のフォルダ検索

Posted at

forfilesコマンドを使用して、あるフォルダ内にある数字名のフォルダのみをzip圧縮したいと考えております。

ひとまず以下コマンドで検索してみたのですが、うまく意図した検索結果が得られません。
数字名のフォルダの指定の個所が誤っていると思われるのですが、数字名フォルダを検索する方法をご教示いただきたく、よろしくお願いします。

階層(TESTFOLDER下は全てフォルダです)
D:\TESTFOLDER
|_20250128
|_20250129
|_20250130
|_MMM
|_YYY

実行したコマンド①

forfiles /P "D:\TESTFOLDER" /M "[0-9]+" /C "cmd /c if @isdir==TRUE echo @path"
結果
エラー: 種類が "[0-9]+" のファイルが見つかりません。

実行したコマンド②
forfiles /P "D:\TESTFOLDER" /M "*" /C "cmd /c if @isdir==TRUE if @fname==[0-9]+ echo @path"
結果
検索しているようだが、何も表示されずにコマンド終了(@fnameでも@fileでも結果は同様)

実行したコマンド③
forfiles /P "D:\TESTFOLDER" /M "*" /C "cmd /c if @isdir==TRUE echo @path"
結果
TESTFOLDER下のフォルダがすべて表示される
|_20250128
|_20250129
|_20250130
|_MMM
|_YYY

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?