I tired to create batch files to automate the copy and delete commands for files and folders.

It seams that windows xp does not support long file or folder names with space. Hence my batch files do not work.

Please advise.

Thanks
muthu snk

Dani AI

Generated

Windows XP itself supports long file names and spaces. The usual cause of batch failures is how the command interpreter parses arguments — not an OS limitation. The quick tips from and (use quotes) and the 8.3 short-name fallback from are on the right track; below are practical, reliable ways to handle names with spaces and some common pitfalls to watch for.

A robust pattern for batches that accept path arguments is to strip any surrounding quotes when assigning and then always wrap variables in quotes when using them. Example:

@echo off
set "SRC=%~1"
set "DST=%~2"
if "%SRC%"=="" echo Usage: %~nx0 "source" "destination" & exit /b 1
copy "%SRC%" "%DST%"

When iterating files from a list or command output, preserve spaces with for /f "usebackq delims=" and remember to use %% in batch files (single % at the prompt):

for /f "usebackq delims=" %%F in ("list.txt") do copy "%%F" "C:\Backup\"

Troubleshooting checklist:

  • Run the same copy/delete commands interactively with quoted paths to see exact errors.
  • Use dir /x to view short (8.3) names if you want the ~1 fallback — note 8.3 creation can be disabled on some NTFS volumes.
  • Prefer xcopy or robocopy (robocopy comes with the resource kit) for recursive folder work.
  • Avoid delayed-expansion issues (filenames with !) or extra whitespace when using set.
  • Add echo or pause in scripts to inspect expanded variables before destructive operations.

These steps cover the common causes of the behavior you described and will make batch copying/deleting work reliably with filenames and folders that contain spaces.

Recommended Answers

All 4 Replies

Put the names between quotation marks

Put the names between quotation marks

Spot-on advice.

Just to clarify, if you had a file named december sales report.xls, you would enter it as:

"december sales report.xls"

Note the quotation marks-- it tells the interpreter that everything in between the quotes is one item.

Spot-on advice.

Just to clarify, if you had a file named december sales report.xls, you would enter it as:

"december sales report.xls"

Note the quotation marks-- it tells the interpreter that everything in between the quotes is one item.

Thank You for your tips.

Thank You for your tips.

just specify the first 6 letters of file name and then add "~1" to it
and if u have any extensions then add it no problem

now it will work..

XP will automatically translate it to approppriate file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.