Simple script to use an text editor and temp file and some code to create files or folders or whole paths in current directory.
Sure, a AutoHotkey script with GUI is nicer, have more features, but is not better at the end, and this script should work without any additional tools you must install.
So just use your favorite text editor to manipulate the list of file names.
'// #######################################################
'// USAGE
'// #######################################################
'// 1) Save this code as "CreateFilesFromList.vbs" in TC-folder
'// 2) Create in TC as Button like shown below
'// 3) Open in TC the wanted folder to create the files
'// 4) Click at that button
'// 5) Notepad will open the sTempFile for modifying
'// Best use a better Texteditor with RegEx support
'// like Notepad2 from Florian Balmer (http://www.flos-freeware.ch/)
'// 6) Write or paste file or folder name or whole path, one by line
'// After names of folders there must be a trailing backslash \ !
'// 7) Save the file
'// 8) You are asked to continue or not
'// Done
'//
Einfaches Skript um mittels eines Texteditors und einer temporären Datei und ein bisschen Code Dateien oder Ordner oder komplette Pfade im aktuellen Verzeichnis zu erstellen.
Ein AutoHotkey-Skript mit einer GUI ist sicherlich netter, hat mehr Möglichkeiten, aber ist im Endeffekt auch nicht besser, und dieses Skript sollte für alle funktionieren, ohne zusätzliche Tools installieren zu müssen.
Verwende einfach deinen Lieblingseditor um die Liste der Dateinamen zu modifizieren.
'// #######################################################
'// Verwendung
'// #######################################################
'// 1) Speichere diesen Code als "CreateFilesFromList.vbs" im TC-Ordner
'// 2) Erstelle im TC einen Button wie unten gezeigt
'// 3) Öffne im TC den Ordner, in welchem die Dateien erstellt werden sollen
'// 4) Klicke auf den Button
'// 5) Notepad öffnet die sTempFile-Datei zum editieren
'// Am Besten verwende einen Texteditor mit RegEx-Unterstützung
'// wie z.B. Notepad2 von Florian Balmer (http://www.flos-freeware.ch/)
'// 6) Schreibe oder kopiere Datei- oder Ordnernamen oder ganze Pfade, je einen pro Zeile
'// Den Ordnernamen muss ein Backslash\Schrägstrich \ folgen!
'// 7) Speichere diese Liste
'// 8) Du wirst gefragt ob weitergemacht werden soll oder nicht
'// Erledigt
'//
'// #######################################################
'// TC Button
'// #######################################################
'// Command: "%Commander_Path%\CreateFilesFromList.vbs"
'// Parameters:
'// Start path: <LEER lassen!!!> <MUST be empty!!!>
'// Icon file: wciconex.dll
'// Icon: 3
'// Tooltip: CreateFilesFromList.vbs (Text to display as tooltip)
'//
The script // Das Skript:
CreateFilesFromList.vbs 2023 , nothing new, only script simplified
Code: Select all
'// CreateFilesFromList.vbs
'// Create Files and Folders in current Folder
'// Stefan 15:50 Montag, 22. Januar 2018
'// Stefan 12:51 Samstag, 10. Juni 2023 nothing new, only script simplified
'//
MyDebug=1
'//
'// #######################################################
'// USAGE
'// #######################################################
'// 1) Save this code as "CreateFilesFromList.vbs" in TC-folder
'// 2) Create in TC as Button like shown below
'// 3) Open in TC the wanted folder to create the files
'// 4) Click at that above created button (or just execute the VBS from that folder)
'// 5) Notepad will open the sTempListFile for modifying
'// Best use a better Texteditor with RegEx support
'// like Notepad2 from Florian Balmer (http://www.flos-freeware.ch/)
'// 6) Write or paste file or folder name or whole path, one by line
'// After names of folders there must be always a trailing backslash \ !!! IMPORTANT
'// 7) Save the file
'// 8) You are asked to continue or not
'// Done
'//
'// #######################################################
'// Example File list
'// #######################################################
'C:\TotalCmd\d\TASTEN.TXT
'C:\TotalCmd\e\KEYBOARD.TXT
'C:\TotalCmd\Folder only\
'C:\TotalCmd\LANGUAGE\WCMD_DEU.INC
'C:\TotalCmd\LANGUAGE\WCMD_DEU.LNG
'C:\TotalCmd\LANGUAGE\WCMD_DEU.MNU
'//
'// #######################################################
'// TC Button
'// #######################################################
'// Command: "TOOLs\CMDs\CreateFilesFromList.vbs"
'// Parameters:
'// Start path: <LEER lassen!!!> <MUST be empty!!!>
'// Icon file: wciconex.dll
'// Icon: 3
'// Tooltip: CreateFilesFromList.vbs (Text to display as tooltip)
'//
'// #######################################################
'// Script basics
'// #######################################################
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSO = CreateObject("WScript.Shell")
sTCPath = WSO.ExpandEnvironmentStrings("%Commander_Path%")
CurrentWorkDir = WSO.CurrentDirectory
UserTEMP = WSO.ExpandEnvironmentStrings("%tmp%")
SysTEMP = SystemRoot & "\Temp"
HostName = WSO.ExpandEnvironmentStrings("%ComputerName%")
UserName = WSO.Environment("process") ("username")
UserProfile = WSO.ExpandEnvironmentStrings("%USERPROFILE%")
PrgFiles = WSO.ExpandEnvironmentStrings("%ProgramFiles%")
PrgFiles86 = WSO.ExpandEnvironmentStrings("%ProgramFiles(x86)%")
'//
'// #######################################################
'// USER SETTINGS
'// #######################################################
'// Set the text editor for to show and edit the temp file:
sUsersTextEditor="Notepad.exe"
sUsersTextEditor = chr(34) & sTCPath & "\TOOLs\NotePad2\notepad2.exe" & chr(34)
'sUsersTextEditor = chr(34) & PrgFiles & "\EmEditor\EmEditor.exe" & chr(34)
'//
'// Set location and name for the temp file:
'// (This file will be opened in notepad and store the list of wanted file to create)
'// (After you have saved that file, the MsgPrgFilesBox will appear to ask to create that files or not)
sTempListFile = sTCPath & "\CreateFilesFromList.txt"
'sTempListFile = sTCPath & "\TOOLs\CMDs\CreateFilesFromList.txt"
'sTempListFile = UserTEMP & "\totalcmdCreateFilesFromList.txt"
'If Wscript.arguments.Count > 0 Then sTempListFile = Wscript.arguments.Item(0)
If NOT FSO.FileExists(sTempListFile) Then FSO.CreateTextFile(sTempListFile)
'//
'// Always start with a clean, emtpy file (leave disabled to keep the last content)
' If FSO.FileExists(sTempListFile) Then FSO.DeleteFile(sTempListFile)
'//
'// #######################################################
'// DEBUG
'// #######################################################
If(MyDebug) THEN
MB = MsgBox("DEBUG:" _
&vbLF& "sTempListFile: " &vbTab& sTempListFile _
&vbLF& "sUsersTextEditor: " &vbTab& sUsersTextEditor _
&vbLF& "CurrentWorkDir: " &vbTab& CurrentWorkDir ,vbOKCancel+vbQuestion,"TC - CreateFilesFromList.vbs")
If (MB = vbCancel) Then WScript.Quit
End If
'// #######################################################
'// THE CODE
'// #######################################################
'//
'// Show temp file content:
WSO.Run sUsersTextEditor & " " & chr(34) & sTempListFile & chr(34), 1, True
'//
MB = MsgBox("OK to create the files in this folder?"&vbLF&CurrentWorkDir&"\",vbOKCancel+vbQuestion,"TC - CreateFilesFromList.vbs")
If (MB = vbCancel) Then WScript.Quit
'//
Set objStream = CreateObject("ADODB.Stream")
objStream.CharSet = "utf-8"
objStream.Open
objStream.LoadFromFile(sTempListFile)
strData = objStream.ReadText()
objStream.Close
sItems=split(strData,vbcrlf)
For i=0 to ubound(sItems)
strCurrItem = sItems(i)
If(strCurrItem <> "") Then
strCurrItem = CleanUpTheNames(strCurrItem)
If Right(strCurrItem,1) = "\" Then
Create_FolderStructure(strCurrItem)
ElseIf InStr(strCurrItem, "\") > 0 Then
sPartPath = FSO.GetParentFolderName(strCurrItem)
sPartFile = FSO.GetFileName(strCurrItem)
Create_FolderStructure(sPartPath)
FSO.CreateTextFile sPartPath&"\"&sPartFile
Else
FSO.CreateTextFile strCurrItem
End If
End If
Next
'// #######################################################
'// Helper functions:
'// #######################################################
'-------------------------------------------------------
'create_Folder with all needed parent-folders in between
'-------------------------------------------------------
Function Create_FolderStructure(strPath)
On Error Resume Next
strParentPath = FSO.GetParentFolderName(strPath)
If Not FSO.FolderExists(strParentPath) Then Create_FolderStructure strParentPath
If Not FSO.FolderExists(strPath) Then FSO.CreateFolder strPath
Create_FolderStructure = FSO.FolderExists(strPath)
End Function 'Create_FolderStructure
'-------------------------------------------------------
Function CleanUpTheNames(sInput)
On Error Resume Next
'remove non-valid invalid chars
' MS Question Q177506: A filename cannot contain any of the following characters: \ / : * ? " < > |
sInput = replace(sInput,"/","\")
sInput = replace(sInput,":","")
sInput = replace(sInput,"?","")
sInput = replace(sInput,"*","")
sInput = replace(sInput,"<","")
sInput = replace(sInput,">","")
sInput = replace(sInput,"|","")
sInput = replace(sInput,chr(34),"")
CleanUpTheNames = sInput
End Function 'CleanUpTheNames
'-------------------------------------------------------
REM ############### This is the END my friend ##############
CreateFilesFromList.vbs 2018
Code: Select all
'// CreateFilesFromList.vbs
'// Create Files and Folders in current Folder
'// Stefan 15:50 Montag, 22. Januar 2018
'//
'// #######################################################
'// USAGE
'// #######################################################
'// 1) Save this code as "CreateFilesFromList.vbs" in TC-folder
'// 2) Create in TC as Button like shown below
'// 3) Open in TC the wanted folder to create the files
'// 4) Click at that button
'// 5) Notepad will open the sTempFile for modifying
'// Best use a better Texteditor with RegEx support
'// like Notepad2 from Florian Balmer (http://www.flos-freeware.ch/)
'// 6) Write or paste file or folder name or whole path, one by line
'// After names of folders there must be a trailing backslash \ !
'// 7) Save the file
'// 8) You are asked to continue or not
'// Done
'//
'// #######################################################
'// Verwendung
'// #######################################################
'// 1) Speichere diesen Code als "CreateFilesFromList.vbs" im TC-Ordner
'// 2) Erstelle im TC einen Button wie unten gezeigt
'// 3) Öffne im TC den Ordner, in welchem die Dateien erstellt werden sollen
'// 4) Klicke auf den Button
'// 5) Notepad öffnet die sTempFile-Datei zum editieren
'// Am Besten verwende einen Texteditor mit RegEx-Unterstützung
'// wie z.B. Notepad2 von Florian Balmer (http://www.flos-freeware.ch/)
'// 6) Schreibe oder kopiere Datei- oder Ordnernamen oder ganze Pfade, je einen pro Zeile
'// Den Ordnernamen muss ein Backslash\Schrägstrich \ folgen!
'// 7) Speichere diese Liste
'// 8) Du wirst gefragt ob weitergemacht werden soll oder nicht
'// Erledigt
'//
'// #######################################################
'// TC Button
'// #######################################################
'// Command: "%Commander_Path%\TOOLs\CMDs\CreateFilesFromList.vbs"
'// Parameters:
'// Start path: <LEER lassen!!!> <MUST be empty!!!>
'// Icon file: wciconex.dll
'// Icon: 3
'// Tooltip: CreateFilesFromList.vbs (Text to display as tooltip)
'//
'// #######################################################
'// Script basics
'// #######################################################
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSO = CreateObject("WScript.Shell")
sTCPath = WSO.ExpandEnvironmentStrings("%Commander_Path%")
CurrentWorkDir = WSO.CurrentDirectory
'//
'// #######################################################
'// USER SETTINGS
'// #######################################################
'// Set the text editor for to show and edit the temp file:
sUsersTextEditor="Notepad.exe"
'sUsersTextEditor = chr(34) & sTCPath & "\TOOLs\NotePad2\notepad2.exe" & chr(34)
'//
'// Set location and name for the temp file:
sTempFile = sTCPath & "\CreateFilesFromList.txt"
'//
'// Always start with a clean, emtpy file (leave disabled to keep the last content)
' If FSO.FileExists(sTempFile) Then FSO.DeleteFile(sTempFile)
'//
'// Set location and name for the store file if wanted (to store entries for longer):
sSTOREFile = sTCPath & "\CreateFilesFromListSTORE.txt"
'If NOT FSO.FileExists(sSTOREFile) Then FSO.CreateTextFile(sSTOREFile)
'WSO.Run sUsersTextEditor & " " & chr(34) & sSTOREFile & chr(34), 1, True
'//
'// #######################################################
'// THE CODE
'// #######################################################
'// Show temp file content:
If NOT FSO.FileExists(sTempFile) Then FSO.CreateTextFile(sTempFile)
WSO.Run sUsersTextEditor & " " & chr(34) & sTempFile & chr(34), 1, True
'//
MB = MsgBox("OK to create the files in this folder?"&vbLF&CurrentWorkDir&"\",vbOKCancel+vbQuestion,"TC - CreateFilesFromList.vbs")
If (MB = vbCancel) Then WScript.Quit
'//
Set objStream = CreateObject("ADODB.Stream")
objStream.CharSet = "utf-8"
objStream.Open
objStream.LoadFromFile(sTempFile)
strData = objStream.ReadText()
objStream.Close
sItems=split(strData,vbcrlf)
For i=0 to ubound(sItems)
strCurrItem = sItems(i)
If(strCurrItem <> "") Then
strCurrItem = CleanUpTheNames(strCurrItem)
If Right(strCurrItem,1) = "\" Then
Create_FolderStructure(strCurrItem)
ElseIf InStr(strCurrItem, "\") > 0 Then
sPartPath = FSO.GetParentFolderName(strCurrItem)
sPartFile = FSO.GetFileName(strCurrItem)
Create_FolderStructure(sPartPath)
FSO.CreateTextFile sPartPath&"\"&sPartFile
Else
FSO.CreateTextFile strCurrItem
End If
End If
Next
'// #######################################################
'// Helper functions:
'// #######################################################
'-------------------------------------------------------
'create_Folder with all needed parent-folders in between
'-------------------------------------------------------
Function Create_FolderStructure(strPath)
On Error Resume Next
strParentPath = FSO.GetParentFolderName(strPath)
If Not FSO.FolderExists(strParentPath) Then Create_FolderStructure strParentPath
If Not FSO.FolderExists(strPath) Then FSO.CreateFolder strPath
Create_FolderStructure = FSO.FolderExists(strPath)
End Function
Function CleanUpTheNames(sInput)
On Error Resume Next
'remove non-valid invalid chars
' MS Question Q177506: A filename cannot contain any of the following characters: \ / : * ? " < > |
sInput = replace(sInput,"/","\")
sInput = replace(sInput,":","")
sInput = replace(sInput,"?","")
sInput = replace(sInput,"*","")
sInput = replace(sInput,"<","")
sInput = replace(sInput,">","")
sInput = replace(sInput,"|","")
sInput = replace(sInput,chr(34),"")
CleanUpTheNames = sInput
End Function 'CleanUpTheNames
REM ############### This is the END my friend ##############
Hintergrund infos
Liste mit Namen werden oft im Forum geposted (Beispiel https://ghisler.ch/board/viewtopic.php?p=410302#p410302 ),
du kannst auch deine eigene Liste erstellen,
zum Beispiel mit Menü "Markieren > Kopiere markierte Namen in die Zwischenablage".
Oder ganze Verzeichnisse zB über das CatalogMaker.wcx (Packer-Plugin) von Polyakov Konstantin
Solch eine Liste mit allen Unterordnern kann man zB auch mit einem PowerShell-Skript erstellen:
Get-ChildItem -Recurse|ForEach{if($_.PSISCOntainer){$_.Name+'\'}else{$_.Name}}|out-file "__List3.txt"
oder
Get-ChildItem -Recurse|ForEach{if($_.PSISCOntainer){$_.Name+'\'}else{$_.FullName}}|out-file "__List3.txt"
Die Testdateien kann man auch mittels eines weiteren PowerShell-Skript erstellen, hier jetzt ohne Vorschau im Texteditor:
Get-Content __List3.txt|ForEach{$ITEM=$_ -replace':'; if($ITEM[-1] -eq '\'){new-item $ITEM -it dir}else{new-item $ITEM -it file}}|Out-Null
Example list // Beispielsliste:
folder1\SubFolder1\
folder1\SubFolder2\
folder2\SubFolder2\
folder3\SubFolder3\
oder:
d\TASTEN.TXT
d\TOTALCMD.CHM
e\KEYBOARD.TXT
e\TOTALCMD.CHM
LANGUAGE\WCMD_CHN.LNG
LANGUAGE\WCMD_CHN.MNU
LANGUAGE\WCMD_CHN.INC
plugins\
plugins\wcx\
plugins\wcx\TreeCopyPlus\
plugins\wcx\TreeCopyPlus\ReadmeEng.txt
CABRK.DLL
DEFAULT.BAR
descript.ion
HISTORY.TXT
TOTALCMD.INC
TOTALCMD.CHM
TOTALCMD.EXE
wcx_ftp.ini
WINCMD.INI
oder auch:
C:\TotalCmd\d\
C:\TotalCmd\e\
C:\TotalCmd\LANGUAGE\WCMD_DEU.INC
C:\TotalCmd\LANGUAGE\WCMD_DEU.LNG
C:\TotalCmd\LANGUAGE\WCMD_DEU.MNU
was dann dies im aktuellen Ordner erzeugt:
C\TotalCmd\d
C\TotalCmd\e
C\TotalCmd\LANGUAGE\WCMD_DEU.INC
C\TotalCmd\LANGUAGE\WCMD_DEU.LNG
C\TotalCmd\LANGUAGE\WCMD_DEU.MNU
oder:
Tests\MediaFiles\MP3s\Hebert Grönemeyer - Männer.mp3
Tests\MediaFiles\MP3s\Kansas - Dust in the wind.mp3
Tests\MediaFiles\MP3s\Led Zeppelin - Stairway to heaven (remastered version).mp3
Tests\MediaFiles\Videos\Marius Müller-Westernhagen - Freiheit.flv
Tests\MediaFiles\MP3s\Meat loaf - I'd do anything for love (but I won't do that).mp3
Tests\MediaFiles\Videos\Bonnie Tyler - Holding out for a hero.mp4
Ähnliche AHK-Skripts poste ich mal bei Gelegenheit
- - -
Here is a older but simple to use version of my "Dummy File Creator" v05c
for to create empty zero-byte files and folders (incl. sub folders)
- create a new text file in TCs folder (or sub folder, f.ex. named "Tools".
- name that file "AHK_FileCreater_v05c.b64".
- copy the b64 content from
https://github.com/Stefan2Nafets/DFCv05c/blob/main/b64
to that file and save it.
- select that file named "AHK_FileCreater_v05c.b64".
- open menu "Files > Decode File...".
- take care on the shown path to where to create the decoded content
(remove it to create in the current directory).
- you should get a file named "AHK_FileCreater_v05c.exe".
- you can double click it and just use it.
- for real usage created an button to use this tool on just the current directory, where ever that is:
--- drag&drop the exe to the button bar.
--- right click that button and chose "Change..."
--- you may make the "Command" and "Icon file" portable
by changing
"C:\path to\Totalcmd\Tools\AHK_FileCreater_v05c.exe"
to
"%Commander_Path%\Tools\AHK_FileCreater_v05c.exe"
--- make the "Start path" empty !
--- you may want to modify the "Tooltip".
---
---
--- now go to an wanted folder.
--- click that button.
--- enter the file or folder names (folder names always with trailing backslash !)
--- click [OK]-button to create.
---
Find me: create dummy files zero byte 0-byte erstelle testdateien