I'm trying to figure out a way to rename Desktop.ini to *.ini and back again. The problem is I need to do this with the attributes in tact (So I cannot remove hidden and system and then rename). The only solution I have come up with is xcopy and del but I am having trouble with the syntax on options, source options and destination options.
This is what I have come up with:
@ECHO OFF
xcopy /H /R Desktop.ini Desktop.txt /K
del /Q /AHS Desktop.ini
xcopy /H /R Desktop.txt Desktop.ini /K
del /Q /AHS Desktop.txt
Pause
exit /b
To unhide a file, go to the folder containing the hidden file and click the view options button in the toolbar and pick Show Hidden Files. Then, find the hidden file and rename it so that it does not have a . in front of its name.
Right-click on the item and select Rename, or select the file and press F2 . Type the new name and press Enter or click Rename.
Using the command line command dir /ah displays the files with the Hidden attribute. In addition, there is a System file attribute that can be set on a file, which also causes the file to be hidden in directory listings. Use the command line command dir /as to display the files with the System attribute.
When using ren
you must remove hidden
and system
flags, rename the file, then set the flags again:
attrib -s -h desktop.ini
ren desktop.ini desktop.txt
attrib +s +h desktop.txt
If you can't do that, you have to use something else, e.g. VBScript:
Set fso = CreateObject("Scripting.FileSystemObject")
fso.GetFile(WScript.Arguments(0)).Name = WScript.Arguments(1)
or PowerShell:
Rename-Item 'desktop.ini' 'desktop.txt' -Force
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With