- 1 year ago
How to get a .BIN extension for a file name in a cmd, obtained from a variable off a text file (using powershell)
Assuming that you have a text file that contains the name of the file without the .BIN
extension, and you want to add the extension to the filename using PowerShell, you can use the following command:
powershell$filename = Get-Content -Path "C:\path\to\textfile.txt"
$filename = $filename + ".BIN"
This will read the contents of the text file into the $filename
variable and then append the .BIN
extension to the variable.
If you want to rename the file with the new extension, you can use the Rename-Item
cmdlet:
powershellRename-Item -Path "C:\path\to\oldfile" -NewName "$filename"
Replace C:\path\to\oldfile
with the path to the old file that you want to rename. The $filename
variable will contain the new name of the file with the .BIN
extension appended.
Alternatively, you can use the Set-Content
cmdlet to write the new filename to a new text file:
powershellSet-Content -Path "C:\path\to\newfile.txt" -Value "$filename"
This will create a new text file named newfile.txt
with the new filename and extension in the specified path.