Windowsで一連のフォルダー(000-999)をバッチ作成する方法は?


16

ディレクトリ内に000〜999という番号の1000個のフォルダーを作成する必要があります。cmd(Windowsコマンドラインなど)を使用してこれを行うにはどうすればよいですか?


これらのような問題は、私がたいてい人々をpythonに向けることです。Windowsのコマンドラインは強力とはほど遠い、IMOはそれを補うために何かを必要とします。
Phoshi

1
私はちょうど...いけないが、ちょうどそのためのpythonをインストールしたい、一度それを行う必要がある
user11955

1
いや、あなたは他の事のためにPythonを保持します;)
イグナシオバスケス-エイブラムス

回答:


28
for /l %i in (0,1,9) do md 00%i
for /l %i in (10,1,99) do md 0%i
for /l %i in (100,1,999) do md %i

ドキュメントの説明(for /?コマンドプロンプトで入力する):

Runs a specified command for each file in a set of files.

FOR %variable IN (set) DO command [command-parameters]

  %variable  Specifies a single letter replaceable parameter.
  (set)      Specifies a set of one or more files.  Wildcards may be used.
  command    Specifies the command to carry out for each file.
  command-parameters
             Specifies parameters or switches for the specified command.

...

FOR /L %variable IN (start,step,end) DO command [command-parameters]

    The set is a sequence of numbers from start to end, by step amount.
    So (1,1,5) would generate the sequence 1 2 3 4 5 and (5,-1,1) would
    generate the sequence (5 4 3 2 1)

1
これはある種の外国語ですか?いずれにせよ、それはうまくいきます!ありがとう!
user11955

驚くばかり!試したところです。構文を説明したり、説明へのリンクを提供したりしますか?
クリストファーボトムズ

1
@ChristopherBottoms:構文をすでに理解していることを願っています。それでも必要な場合は、cmdウィンドウに移動して/?を入力します。
コーディズム

驚異的な答え!
Brainmaniac

-1
@ECHO OFF && CLS

SET /P x=Insert the name of the place: 
SET /P y=Insert de number of the records: 

SET /A start=1
SET /A z=y+1

REM start the loop
:MKDIR

REM make the directory
MKDIR %x%"__"%start%

REM increment by 1
SET /A start=start+1

REM if we're at the end, return
IF %start%==%z% (GOTO :EOF) ELSE (GOTO :MKDIR)

.batファイルとして機能します
NeoMati

機能しません。OPは0プレフィックス(000-999)の名前を必要とし、プレフィックスのない数字のみが必要です。あなたのコードは0プレフィックスなしの数字を生成し、また奇妙なプレフィックスを追加しました。たとえば、場所の名前がされている場合abc、あなたが作成しabc"__"0abc"__"1... abc"__"10...abc"__"999
phuclv
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.