Copying files with spaces, commas, etc.

Jun 11, 2008
14
1
66
Washington,DC
I download a lot of pictures for jigsaw puzzles. Then put a random number prefix on the file names so I can mix up groups of the same kind of picture.

For some reason I can't get files with spaces, commas and, such to copy. I've tried:

double quoting just the "%variable"
double quoting "drive\directory\%variable"

Also with single quotes and back quotes ( ` ).

If I try and move a file "test file.jp6" I get the following

TCC: (Sys) D:\tmp_y\Move_test.btm [15] The system cannot find the file specified.
"D:\tmp_y\Test"
TCC: (Sys) D:\tmp_y\Move_test.btm [15] The system cannot find the file specified.
"D:\tmp_y\File.jg6"

Here's the code:

Code:
@echo off
setlocal
:Main
    on Break goto Done
    dir /b D:\tmp_y\*.jg* > FileList.x
    setdos /x-45678
    set FileHandle=%@fileopen["FileList.x",r,t]
    set FileName=%@fileread[%FileHandle]
    set DirNum=0
    set x=0
    Do while %FileName ne **EOF**
        If %@len[%DirNum] lt 2 set DirNum=0%DirNum
        If not exist "d:\Games\BigJig\My_Jigsaws_%DirNum" md "d:\Games\BigJig\My_Jigsaws_%DirNum"
        set x=%@inc[%x]
        move /q "d:\tmp_y\%FileName" "d:\Games\BigJig\My_Jigsaws_%DirNum\"
        set FileName=%@fileread[%FileHandle]
        If %x eq 100 echo Moved to My_Jigsaws_%DirNum
        If %x eq 100 set DirNum=%@inc[%DirNum]
        If %x eq 100 set x=0
    enddo
:Done
    set FileHandle=%@fileclose[%FileHandle]
    del /q FileList.x
    endlocal
    pause
    quit

Edited code to reflect what I have done since I update to ver. 21. 2017-11-14 19:22
 
Last edited:

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,446
88
Albuquerque, NM
prospero.unm.edu
It looks to me like you have double-quotes within double-quotes: one from line 8 (or 16), and one from line 15. They aren't nestable. You probably want to remove the double-quotes from your @FILEREAD lines.
 
Jun 11, 2008
14
1
66
Washington,DC
Charles, without the quote around %@fileread[%FileHandle], after giving the error from my first post, it goes in to an endless loop repeating:

TCC: (Sys) D:\tmp_y\Move_test.btm [15] The system cannot find the file specified.
"D:\tmp_y\**EOF**"

I've already tried "D:\tmp_y\"%FileName"" and gotten the same error as my first message.

If it makes a difference I'm running:

TCC 19.10.54 x64 Windows 10 [Version 6.3.16299]
TCC Build 54 Windows 10 Build 16299
 
Jun 11, 2008
14
1
66
Washington,DC
I upgraded to:
TCC 21.01.60 x64 Windows 10 [Version 10.0.16299]
TCC Build 60 Windows 10 Build 16299

Unquoted the %@fileread[%FileHandle] and that now works.

However, I'm still getting:
TCC: (Sys) D:\tmp_y\Move_test.btm [15] The system cannot find the file specified.
"D:\tmp_y\Test"
TCC: (Sys) D:\tmp_y\Move_test.btm [15] The system cannot find the file specified.
"D:\tmp_y\File.jg6"

Updated the code in my first post.
 
Apr 2, 2011
1,427
10
54
North Carolina, USA
I would double quote any place where you are using, not setting, Filename.......

Code:
@echo off
setlocal
:Main
    on Break goto Done
    dir /b D:\tmp_y\*.jg* > FileList.x
    setdos /x-45678
    set FileHandle=%@fileopen["FileList.x",r,t]
    set FileName=%@fileread[%FileHandle]
    set DirNum=0
    set x=0
    Do while "%FileName" ne "**EOF**"
        If %@len[%DirNum] lt 2 set DirNum=0%DirNum
        rem Below, why not use if not isdir ....?
        If not exist "d:\Games\BigJig\My_Jigsaws_%DirNum" md "d:\Games\BigJig\My_Jigsaws_%DirNum"
        set x=%@inc[%x]
        move /q "d:\tmp_y\%FileName" "d:\Games\BigJig\My_Jigsaws_%DirNum\"
        set FileName=%@fileread[%FileHandle]
        iif %x eq 100 then
            echo Moved to My_Jigsaws_%DirNum
            set DirNum=%@inc[%DirNum]
            set x=0
        endiff
    enddo
:Done
    set FileHandle=%@fileclose[%FileHandle]
    del /q FileList.x
    endlocal
    pause
    quit
 
Jun 11, 2008
14
1
66
Washington,DC
Solved

It was the "setdos /x-45678" line. I had seen the line in a thread here concerning copying files with foreign language characters. Which I do get sometimes.
 
Similar threads
Thread starter Title Forum Replies Date
P Copying files in subdirectories Support 9
S iftp copying pgp files from ftp is not working Support 11
rps Documentation Help file revision - Copying hidden DESCRIPT.ION files Support 19
M Copying files (NOT file contents) to clipboard from TCC Support 17
Charles Dye Difficulty copying DESCRIPT.ION files Support 1
Roedy copying files to DVD or CD Support 3
D When copying/moving, appending " (2)" to filename when the target file already exist. Support 7
P Copying descript.ion file fails Support 8
JohnQSmith Fixed Copying with regex (several issues) Support 7
S Copying descriptions in DESCRIPT.ION Support 3
Joe Caverly Copying text of MSGBOX Support 0
P Copying descriptions Support 4
samintz How to? exclude a subdirectory when copying Support 2
S COPYing attributes Support 3
K Copying and mouse Support 0
CWBillow Windows 7 copying and Take Command Support 5
A GPF when copying large amount of data on busy USB Drive Support 3
p.f.moore Copying Take Command installed folder Support 19
C v28 key files Support 2
J ffind does not find files Support 4
C duplicate files in multiple plugin sites Support 9
Dmitry L. Kobyakov Fixed The SETARRAY /R command works incorrectly with cyrillic files Support 2
S How to? Deinstalling TC/reinstating execution of bat files by cmd in Win7 Support 31
vefatica FFIND, temp files? ... not deleted? Support 0
R FUNCTION to count NUMBER of files matching a pattern and specific length/not length Support 4
vefatica Tmp files from in-process pipes not deleted Support 6
vefatica Finding files with alternate data streams? Support 4
rps Multi-column DIR /v not displaying all files. Support 5
D How to skip files in a fileset? Support 6
vefatica PIPEVIEW leaves TMP files Support 18
K "copy /z /w" command not deleting read-only files in destination Support 10
Jesse Heines "Taken" date for JPG and PNG files Support 4
O I cannot use links to .btm files Support 5
C How to? rename files with spaces Support 8
R How to? Append files in multiple subfolders using copy? Support 8
Joe Caverly "Functions" in cmd.exe batch files Support 6
S Batch files Calling Batch Files Support 2
vefatica Find Files/Text dialog: does it work? Support 0
Joe Caverly UNZIPping older .ZIP files Support 3
C Documentation default location for LOG files Support 21
P exit /b in batch files Support 7
P Labels in batch files: TCC vs CMD.exe Support 9
M ANSI is used to show files instead of OEM in version 17 to 19 ! Support 5
C 7Z files on forum? Support 0
x13 Problem listing repository files using DIR http(s)://... Support 8
B Can copy command concatenate multiple mp3 files Support 2
J New lexer for TCC batch files. Support 0
M How to? want to download a file from a website enumarate the links and download the files Support 2
keithg1964 TCC RT Install Files Support 1
P Fixed Rexx .cmd files no longer work in TCC 20 Support 3

Similar threads