How to move or copy a file between directories that have spa
How to move or copy a file between directories that have spa
Hi all ! i'm trying to copy a file from one directory like: C:\Users\PC 1\Desktop\ , but its impossible cause he have a space (PC""1), anyone can help me to solve this ?. Thanks
-
- Addict
- Posts: 4777
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: How to move or copy a file between directories that have
It depends on what you do in detailelfo116 wrote:Hi all ! i'm trying to copy a file from one directory like: C:\Users\PC 1\Desktop\ , but its impossible cause he have a space (PC""1), anyone can help me to solve this ?. Thanks

E.g. PB's built-in CopyFile() function does work well also with path names that contain spaces.
In cases like this, it is always a good idea to post the smallest executable code that demonstrates the problem.
Re: How to move or copy a file between directories that have
Little John wrote:It depends on what you do in detailelfo116 wrote:Hi all ! i'm trying to copy a file from one directory like: C:\Users\PC 1\Desktop\ , but its impossible cause he have a space (PC""1), anyone can help me to solve this ?. Thanks![]()
E.g. PB's built-in CopyFile() function does work well also with path names that contain spaces.
In cases like this, it is always a good idea to post the smallest executable code that demonstrates the problem.
Code: Select all
Case 50
booti$ = OpenFileRequester("", "", "img (*.img)|*.img", 0)
If OpenFile(1,booti$)=0:si=0
MessageRequester("Error","",0)
Else
si=1:SetMenuTitleText(0,0,"Cargado")
sep=CountString(booti$,"\")
fileboot$=StringField(booti$,sep+1,"\")
dir$=GetCurrentDirectory()
AddGadgetItem(2,-1,fileboot$)
DisableGadget(0,0)
EndIf
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case 0
AddGadgetItem(2, -1,booti$)
AddGadgetItem(2, -1,dir$)
AddGadgetItem(2, -1, "==> "+fileboot$)
AddGadgetItem(2, -1, booti$+" ==> "+dir$+fileboot$)
copiara$=dir$+"unroot\"+fileboot$
Debug MoveFile_(booti$,copiara$); <----- error copying
Re: How to move or copy a file between directories that have
Better if you provide working code
You can use RenameFile() instead of api movefile_().
When filenames have spaces, enclose them within double quotes, "c:\try\My long crazy filename.txt".

You can use RenameFile() instead of api movefile_().
When filenames have spaces, enclose them within double quotes, "c:\try\My long crazy filename.txt".
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
-
- Addict
- Posts: 4777
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: How to move or copy a file between directories that have
Why don't you use PB's built-in function RenameFile() for moving a file? Like CopyFile(), it works well also with path names that contain spaces.elfo116 wrote:Code: Select all
Debug MoveFile_(booti$,copiara$); <----- error copying
When using the API function MoveFile_(), you probably have to enclose the path names in double quotes:
Code: Select all
Debug MoveFile_(#DQUOTE$+booti$+#DQUOTE$, #DQUOTE$+copiara$+#DQUOTE$)
Re: How to move or copy a file between directories that have
Hi !, like this?:skywalk wrote:Better if you provide working code![]()
You can use RenameFile() instead of api movefile_().
When filenames have spaces, enclose them within double quotes, "c:\try\My long crazy filename.txt".
Code: Select all
RenameFile(Chr(34)+booti$+Chr(34),Chr(34)+copiara$+Chr(34))

Re: How to move or copy a file between directories that have
Debug MoveFile_(#DQUOTE$+booti$+#DQUOTE$, #DQUOTE$+copiara$+#DQUOTE$) still returning (0)Little John wrote:Why don't you use PB's built-in function RenameFile() for moving a file? Like CopyFile(), it works well also with path names that contain spaces.elfo116 wrote:Code: Select all
Debug MoveFile_(booti$,copiara$); <----- error copying
When using the API function MoveFile_(), you probably have to enclose the path names in double quotes:Code: Select all
Debug MoveFile_(#DQUOTE$+booti$+#DQUOTE$, #DQUOTE$+copiara$+#DQUOTE$)
-
- Addict
- Posts: 4777
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: How to move or copy a file between directories that have
If you want us to help you, then you should at least answer our questions ...Little John wrote:Why don't you use PB's built-in function RenameFile() for moving a file? Like CopyFile(), it works well also with path names that contain spaces.
Re: How to move or copy a file between directories that have
Oh sorry, i I did not think that the RenameFile() function served to copy.Little John wrote:If you want us to help you, then you should at least answer our questions ...Little John wrote:Why don't you use PB's built-in function RenameFile() for moving a file? Like CopyFile(), it works well also with path names that contain spaces.
I make a output log with de paths obtained from rename function "C:\Users\PC 1\Desktop\TEMP\boot.img" ===> "C:\Users\PC 1\Desktop\MTKR\unroot\newboot.img"
-
- Addict
- Posts: 4777
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: How to move or copy a file between directories that have
Sometimes you write about copying a file, and sometimes about moving a file. These are two different things.elfo116 wrote:Oh sorry, i I did not think that the RenameFile() function served to copy.
I told you about both PB's built-in CopyFile() and RenameFile().
You can read the details about both functions in the help.
Re: How to move or copy a file between directories that have
Code: Select all
MoveFile_(booti$,copiara$)
Code: Select all
Debug "|"+booti$+"|"
Debug "|"+copiara$+"|"
Re: How to move or copy a file between directories that have
Hello, thanks for your reply. I get:#NULL wrote:no matter if you use RenameFile() or CopyFile() or whatever, but addCode: Select all
MoveFile_(booti$,copiara$)
before and see what you get. Also check if you have write permissions in the directories.Code: Select all
Debug "|"+booti$+"|" Debug "|"+copiara$+"|"
|C:\Users\PC 1\Desktop\TEMP\boot.img|
|C:\Users\PC 1\Desktop\MTKR\unroot\newboot.img|
Re: How to move or copy a file between directories that have
Little John wrote:Sometimes you write about copying a file, and sometimes about moving a file. These are two different things.elfo116 wrote:Oh sorry, i I did not think that the RenameFile() function served to copy.
Haha that's because I've tried all the ways I know to move / copy a file
I told you about both PB's built-in CopyFile() and RenameFile().
You can read the details about both functions in the help.
in the "pb.help" there is no help with this, i tryied

Re: How to move or copy a file between directories that have
As long as you are using Windows API
So search the forum for SHFileOperation_()
It will do the job no matter the filename includes spaces or not
Also no matter the length of the file path
You can Move,Delete,Copy or Rename file(s)
So search the forum for SHFileOperation_()
It will do the job no matter the filename includes spaces or not
Also no matter the length of the file path
You can Move,Delete,Copy or Rename file(s)
Egypt my love
-
- Addict
- Posts: 4777
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: How to move or copy a file between directories that have
Yes, that's a good reason for mixing copying and moving up all the time. I'm glad that we have talked about it.[color=#0000FF](wrong quoting corrected)[/color] elfo116 wrote:Little John wrote:Sometimes you write about copying a file, and sometimes about moving a file. These are two different things.elfo116 wrote:Oh sorry, i I did not think that the RenameFile() function served to copy.elfo116 wrote:Haha that's because I've tried all the ways I know to move / copy a file


Oh, it seems that my calendar is broken.elfo116 wrote:in the "pb.help" there is no help with this, i tryiedLittle John wrote:I told you about both PB's built-in CopyFile() and RenameFile().
You can read the details about both functions in the help.
I totally missed that today is April's Fools day.

