Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to delete a file with spacing?

Status
Not open for further replies.

jloh81

Programmer
Jun 15, 2010
16
US
how to delete a file with spacing?
example:
Hello world.txt

I use the command
file delete Helloworld.txt

the file cant be delete

Can you show me a way?
 
Hi

Code:
[b]file[/b] delete [green][i]"Hello world.txt"[/i][/green]

[gray]# or[/gray]

[b]file[/b] delete [teal]{[/teal]Hello world[teal].[/teal]txt[teal]}[/teal]

[gray]# or[/gray]

[b]file[/b] delete Hello[teal]\[/teal] world[teal].[/teal]txt

Feherke.
 
Just to complete the list:
file delete Hello\040world.txt

_________________
Bob Rashkin
 
Thanks!

i try to delete all file in the directory then i use

file delete {$allsheet}

but it cannot delete all the file.

Here is mycode

set contents [glob -nocomplain *.txt]
set x [llength $contents]
puts $x
while {$x > 0} {
set contents [glob -nocomplain $file *.txt]
foreach item $contents {
#puts $ite
set allsheet [list $item]
#puts $allsheet
}
file delete {$allsheet}
puts "x is $x"
set x [expr {$x - 1}]
}

file delete {$alllist}

can i do like this if i want to delete all the file in the directory

please advice
 
Hi Bob,

what is mean by \040 in the command line?

file delete Hello\040world.txt

please advice

Thanks
 
To delete all *.txt files you can try
Code:
file delete {*}[glob *.txt]
To delete a list of files:
Code:
file delete {*}[list "f.txt" "f1.txt"]
or
Code:
set myfiles [list "f.txt" "f1.txt"]
file delete {*}[eval list $myfiles]
 
the \ followed by a 3-digit octal number will be represented by Tcl as the corresponding character. o040 is space.

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top