Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.
Computer Hope forum e-mail issues and down time
0 Members and 1 Guest are viewing this topic.
Hello All,I was wondering if there is a simple batch command that will go into a dir and convert all the filenames in hex to decimal.
Set fso = CreateObject("Scripting.FileSystemObject")Set WshShell = WScript.CreateObject("WScript.Shell")Set f = fso.GetFolder("c:\temp") 'change directory hereSet fc = f.FilesFor Each fs In fc fname = fso.GetBaseName(fs) fext = fso.GetExtensionName(fs) newName = CLng("&H" & fname) & "." & fext fs.Name = newNameNext
@echo off setlocal enabledelayedexpansion echo abc > 0000.txt echo def > 1000.txt echo ghi > aaaa.txt echo jkl > 000f.txt echo mno > 00ff.txt echo pqr > 0fff.txt echo stu > ffff.txt echo vwx > aef2.txt for /f %%H in ('dir /on /b *.txt') do ( set hexstring=%%~nH set extension=%%~xH set /a decstring=0x!hexstring! set pad= if !decstring! leq 9999 set pad=0!pad! if !decstring! leq 999 set pad=0!pad! if !decstring! leq 99 set pad=0!pad! if !decstring! leq 9 set pad=0!pad! set decstring=!pad!!decstring! echo !hexstring!!extension! =^> !decstring!!extension! )
0000.txt => 00000.txt000f.txt => 00015.txt00ff.txt => 00255.txt0fff.txt => 04095.txt1000.txt => 04096.txtaaaa.txt => 43690.txtaef2.txt => 44786.txtffff.txt => 65535.txt