Hi Jaclaz, thanks for the reply Sorry !%newName! was a typo, it should be !newName! Ok here is the information you asked for. When the CMD file prompts for input at the line set /p groupname=enter groupname: I am entering Accounts Working CMD file @echo off CLS echo. set /p groupname=enter groupname: echo. echo. dsquery * domainroot -filter "(&(objectClass=group)(name=""%groupname%""))" -l -d DomainName -attr member >>GroupMemberExtract.txt CLS setlocal enabledelayedexpansion FOR /F "tokens=1 delims=," %%a IN ( GroupMemberExtract.txt ) DO ( set oldName=%%a set newName=!oldName:~3! echo !newName!>>GroupMemberTrim.txt ) SETLOCAL DISABLEEXTENSIONS :END GroupMemberExtract.txt GroupMemberTrim.txt Non working CMD file with vairables @echo off CLS echo. set /p groupname=enter groupname: echo. echo. dsquery * domainroot -filter "(&(objectClass=group)(name=""%groupname%""))" -l -d DomainName -attr member >>"%groupname%Extract.txt" CLS setlocal enabledelayedexpansion FOR /F "tokens=1 delims=," %%a IN ( "%groupname%Extract.txt" ) DO ( set oldName=%%a set newName=!oldName:~3! echo !newName!>>"%groupname%Trim.txt" ) SETLOCAL DISABLEEXTENSIONS :END AccountsExtract.txt AccountsTrim.txt So as you see, using the variables in this example throws out the %%a in the for loop and instead of phrasing the contents it uses the filename.