![]() |
|
論壇說明 |
歡迎您來到『史萊姆論壇』 ^___^ 您目前正以訪客的身份瀏覽本論壇,訪客所擁有的權限將受到限制,您可以瀏覽本論壇大部份的版區與文章,但您將無法參與任何討論或是使用私人訊息與其他會員交流。若您希望擁有完整的使用權限,請註冊成為我們的一份子,註冊的程序十分簡單、快速,而且最重要的是--註冊是完全免費的! 請點擊這裡:『註冊成為我們的一份子!』 |
|
主題工具 | 顯示模式 |
![]() |
#14 (permalink) | |
管理員
![]() ![]() |
![]() 引用:
這就是程式設計的考量差異 ...,是要用的時候都在改東改西? 還是改個參數就好。 使用 EXECL 或許是很不錯啦,萬一連 OFFICE 軟體都沒有,那可就累了。 我以前就是用記事本在弄,覺得很累,後來知道 "批次檔" 有一些簡單的程式 語法可用時,我就輕鬆多了。 ---------------------------------------------------------------------------------- 以雙重 IF 所構成的值範圍的方式來建構 "大量建置資料夾的批次語法",最大 可新增到 9999 的資料夾 把以下語法方塊的內容,用記事本另存成副檔名 cmd 或 bat 的檔案,主檔隨便 如 MDK.cmd,完成後點兩下該檔案即可。 執行後會問你資料夾的名稱、數量,名稱輸入完按[Entre]、數量輸入完按 [Entre], 運氣好會執行,原因是出在於數量,不能在輸入數量的地方輸入非數字的文字,如AA 、你好、2 2 之類,如此將強制結束。 --> 這是批次檔的問題,很不好除錯,除非用程式解決。 不輸入名稱、數量,直接按 [Enter],會以預設值進行理,(預設:新資料夾,10個) 也可用 CMD 命令的方式下達,如 C:\>MDK /n:阿貓 /t:500 [Enter] 查詢如何使用 CMD 模式,則是 C:\>MDK /? [Enter] 語法:
@Echo off set titles=%0 大量建置系列資料夾名稱的批次檔 ver 0.3 版 TITLE=%titles% set totaldf=10 set namedf=新資料夾 set total=%totaldf% set name=%namedf% if "%1" == "/h" (goto hlp) if "%1" == "/H" (goto hlp) if "%1" == "/help" (goto hlp) if "%1" == "/HELP" (goto hlp) if "%1" == "/?" (goto hlp) if "%1" == "" (goto run3) if "%2" == "" (goto run1) if "%3" == "" (goto run2) goto error :hlp cls echo ============================================================================ echo. %titles% echo. echo. 語法: %0 /n:名稱 /t:數量 echo. echo. 參數 1:%0 /n:名稱 : 指定系列資料夾的名稱 echo. echo. 參數 2:%0 /t:數量 : 指定系列資料夾的建立數量 echo. echo. 參數 3:%0 /? : 說明 echo. echo. echo. echo. ex: %0 /n:圖片 [Enter] 產生名稱為 "圖片" 的資料夾,預設數量 %totaldf% 個 echo. echo. ex: %0 /t:15 [Enter] 產生 15 個,預設系列名稱的資料夾 echo. echo. ex: %0 /n:圖片 /t:15 [Enter] 產生名稱為 "圖片" 的資料夾,預設數量 15 個 echo. echo. echo. echo. 直接執行 %0 [Enter] 時,預設創建 %totaldf% 個 以『%namedf%』為系列名稱的資料夾 echo. echo. echo ============================================================================ goto end :error cls echo ============================================================================ echo. %titles% echo. echo. 語法錯誤! 或 數值錯誤! echo. echo. 語法: %0 /n:名稱 /t:數量 echo. echo. 參數 1:%0 /n:名稱 : 指定系列資料夾的名稱 echo. echo. 參數 2:%0 /t:數量 : 指定系列資料夾的建立數量,1~9999 個 echo. echo. 參數 3:%0 /? : 說明 echo. echo. echo. echo. ex: %0 /n:圖片 [Enter] 產生名稱為 "圖片" 的資料夾,預設數量 %totaldf% 個 echo. echo. ex: %0 /t:15 [Enter] 產生 15 個,預設系列名稱的資料夾 echo. echo. ex: %0 /n:圖片 /t:15 [Enter] 產生名稱為 "圖片" 的資料夾,預設數量 15 個 echo. echo. echo. echo. 直接執行 %0 [Enter] 時,預設創建 %totaldf% 個 以『%namedf%』為系列名稱的資料夾 echo. echo. echo ============================================================================ goto end :run1 set txet1=%1 if "%txet1:~3%" == "" (goto error) if "%txet1:~0,3%" == "/n:" (set name=%txet1:~3% & goto default) if "%txet1:~0,3%" == "/N:" (set name=%txet1:~3% & goto default) if "%txet1:~0,3%" == "/t:" (set total=%txet1:~3% & goto default) if "%txet1:~0,3%" == "/T:" (set total=%txet1:~3% & goto default) goto error :run2 set txet1=%1 set txet2=%2 if "%txet1:~3%" == "" (goto error) if "%txet2:~3%" == "" (goto error) if "%txet1:~0,3%" == "/n:" (set name=%txet1:~3%) if "%txet1:~0,3%" == "/N:" (set name=%txet1:~3%) if "%txet1:~0,3%" == "/t:" (set total=%txet1:~3%) if "%txet1:~0,3%" == "/T:" (set total=%txet1:~3%) if "%txet2:~0,3%" == "/n:" (set name=%txet2:~3% & goto default) if "%txet2:~0,3%" == "/N:" (set name=%txet2:~3% & goto default) if "%txet2:~0,3%" == "/t:" (set total=%txet2:~3% & goto default) if "%txet2:~0,3%" == "/T:" (set total=%txet2:~3% & goto default) goto error :run3 set totalp= set namep= cls echo. %titles% echo. echo. echo 請輸入系列資料夾的名稱: set /p namep= echo. echo. echo 請輸入系列資料夾的建置數量,1~9999 個: set /p totalp= if "%namep%" == "" (echo.) else (set name=%namep%) if "%totalp%" == "" (echo.) else (set total=%totalp%) goto default :default cls set conuter=0 if %total% GEQ 1 if %total% LEQ 9 (goto F1-9) if %total% GEQ 10 if %total% LEQ 99 (goto F1-99) if %total% GEQ 100 if %total% LEQ 999 (goto F1-999) if %total% GEQ 1000 if %total% LEQ 9999 (goto F1-9999) goto error :F1-9 for /L %%V in (1,1,%total%) do ( cls echo. %titles% echo. echo. echo 建立名稱為 %name%%%V 的資料夾 MD "%name%%%V" set /A conuter+=1 ) goto EXIT :F1-99 for /L %%V in (1,1,%total%) do ( cls echo. %titles% echo. echo. echo 建立名稱為 %name%%%V 的資料夾 if %%V GEQ 1 if %%V LEQ 9 (MD "%name%0%%V") else (MD "%name%%%V") set /A conuter+=1 ) goto EXIT :F1-999 for /L %%V in (1,1,%total%) do ( cls echo. %titles% echo. echo. echo 建立名稱為 %name%%%V 的資料夾 if %%V GEQ 1 if %%V LEQ 9 (MD "%name%00%%V") if %%V GEQ 10 if %%V LEQ 99 (MD "%name%0%%V") else (MD "%name%%%V") set /A conuter+=1 ) goto EXIT :F1-9999 for /L %%V in (1,1,%total%) do ( cls echo. %titles% echo. echo. echo 建立名稱為 %name%%%V 的資料夾 if %%V GEQ 1 if %%V LEQ 9 (MD "%name%000%%V") if %%V GEQ 10 if %%V LEQ 99 (MD "%name%00%%V") if %%V GEQ 100 if %%V LEQ 999 (MD "%name%0%%V") else (MD "%name%%%V") set /A conuter+=1 ) goto EXIT :EXIT echo. echo. echo 建立完成,共計 %conuter% 個資料夾 goto end :end echo. echo. pause |
|
![]() |
送花文章: 37855,
![]() |
|
|
![]() |
||||
主題 | 主題作者 | 討論區 | 回覆 | 最後發表 |
????的資料夾和??.txt、???.txt、????.txt文字檔如何開啟? | olda | 軟體應用問題討論區 | 5 | 2005-05-22 11:14 PM |
請問可以在新增資料夾時變更預設'新資料夾' | dubc | 軟體應用問題討論區 | 0 | 2004-03-18 06:13 PM |
無法新增資料夾 | fishon | 軟體應用問題討論區 | 0 | 2003-07-01 12:57 AM |
無法新增資料夾 | aeroexpress | 軟體應用問題討論區 | 4 | 2003-04-27 09:49 PM |