1.

Solve : copy all files and folders from current folder?

Answer»

Quote from: Sidewinder on April 02, 2012, 02:52:59 PM

If you select a folder, and right click the mouse, what do you expect to happen?

A context menu which includes Send To should appear, shouldn't it?


Quote from: mioo_sara on April 02, 2012, 04:16:28 AM
... but cuz source folder is changing every day so program should find the source folder (that is my current folder) and copy any folder and files from there to destination folder (d:\backup) ...
Why not get a freeware file synchronization/backup program such as Allway Sync - there are others but this is one I've used - and use it to achieve your objective? Seems to me this would be easier solution than trying to resort to some DOS technique. Quote from: soybean on April 02, 2012, 06:01:36 PM
Why not get a freeware file synchronization/backup program such as Allway Sync - there are others but this is one I've used - and use it to achieve your objective? Seems to me this would be easier solution than trying to resort to some DOS technique.
I agree. Some Sync utilities can be invoked with a template to automate a task. That might be called 'batch' programming, but it is not just plain DOS. Many programs run from a command line and run a script.

Example:some programs are written in Excel and use VBA. Such business class programs backup and archive files that have been imported. Such are often paid only programs. Some are found on download.com and have free trial.

But not knowing the intent of the OP, it is hard to know if giving bits and pieces of DOS code if he does not understand how to integrate the parts. And it not clear if he wants to invoke the DoS batch code from the GUI or the command line.

IMHO the OP needs to read some tutorials on VBscript and Cscript.
Using the command-based script host (CScript.exe)Quote
As far as I know, this has to be done thru the registry. Is this what you did?

yes i add it thru registry

Quote
But not knowing the intent of the OP, it is hard to know if giving bits and pieces of DOS code if he does not understand how to integrate the parts. And it not clear if he wants to invoke the DoS batch code from the GUI or the command line.
its part of my flash project .unfortunately flash is so week for working with windows so i should do the rest with batch programing !
i used lots of batches and 80% of the job has done so i prefer to do the rest in this way
Quote
its part of my flash project .unfortunately flash is so week for working with windows so i should do the rest with batch programing !
i used lots of batches and 80% of the job has done so i prefer to do the rest in this way

Now I am totally confused. You want to flash the BIOS?
No, you want to write a system utility using Adobe Flash. Huh?

The natural choice for a Flash app is to extend it with Java. But C# would also work. Even current versions of Visual Basic CONTROL FLASH thing.

I have never hears of DOS batch used as a supplement, extension or replacement for Flash. But there is a lot I don't know.

Are you writing a Windows app or a browser app? Browser apps often use JavaScript, vb-scrip, ActiveX or even Java at the client side.

The DOS batch stuff is essentially twenty years old. With a few improvements in recent years. IMHO it is not well suited for browser apps. It is suited for doing backups and archives and removing dead files. Not so good for doing anything visual.

Only 80% of your code works? Did you model the code? You need to get up to 99 % of your code working before working on kinks.
Have you verified the logic and sequence of your code?

A practice of professional programmers is to write a large part of the code in the best programming tool that they can use. Then fill in the tough spots with things imported from other software tools.

I am unable to visualize this with FLASH and DOS batch.
Sorry I can not help you with your quest. But keep at it and eventually you will find a solution. It is not really impossible.

Have you ever read books on structured programming? Or books about program design and incremental refinement ?
Books on structured programming with C#Quote from: Salmon Trout on April 02, 2012, 03:43:30 PM
A context menu which includes Send To should appear, shouldn't it?
I agree. Putting it into the SendTo menu which doesn't require a registry edit works perfectly. I have done that with a few of my batch files over the years.

Another option would be to just drag the source folder onto the batch file which would take it as input in the variable %1.OK. Last try. This goes back to the original question as I understand it or at least how I think I understand it. First up is a VBScript to allow the user the select a folder for the XCOPY operation:

Code: [Select]Const RETURN_ONLY_FOLDERS = &H0001
Const WINDOW_HANDLE = 0
Const MY_COMPUTER = 17

Set objShell = CreateObject( "Shell.Application" )
Set objFolder = objShell.BrowseForFolder( WINDOW-HANDLE, "Select Folder", RETURN_ONLY_FOLDERS, MY_COMPUTER )

'Check For Cancel Button; Nothing Returned
'
If TypeName(objFolder) <> "Nothing" Then
WScript.Echo objFolder.Items.Item.Path
End If

Save the script in any folder with any name and a VBS extension.

Next up is the batch code. Replace the for statement in your existing batch file with the code below:

Code: [Select]set target=D:\Backup
for /f "tokens=* delims=" %%i in ('cscript //nologo drive:\path\scriptname.vbs') do (
if .%%i NEQ . (echo D | xcopy "%%i" %target% /e /c /y > d:\filelist.txt
) ELSE ( goto :eof )
)

Change drive:\path\scriptname.vbs to point to where you saved the VBS script.

The user will be presented with a dialog allowing selection of any folder on the system. Only folders are shown to reduce clutter. Use the left mouse button to highlight the folder name and PRESS OK. The folder path will be returned to the batch file for use by the XCOPY operation. If you CANCEL the folder dialog, the entire batch file will terminate. A file will also be created with a listing of what was copied. (filelist.txt)

Feel free to TWEAK the code as needed.

If you find this useful, then great. If not, well then not so great.

Exit stage left.
dear Geek-9pm

Quote
you want to write a system utility using Adobe Flash. Huh

yes . but i don't use latest version(adobe cs4 or 5) i'm using adobe flash 8
its rather old but unfortunately i should use it .in cs4 or 5 adobe added adobe air so you can work directly with the outside world throu java vb or lots of other scripting languages

Quote
I am unable to visualize this with FLASH and DOS batch

adobe flash 8 has not allowed any command that even think about executing anything(except media ) even opening a window in windows explorer is a big problem ! and you should do lots of scripting tricks!!

Quote
Only 80% of your code works?
no i never said that !! what i mean was my project has reached to 80% and its near to end

by the way thanks for the link
dear Squashman

please read post below i think my bad English is the problem !
dear Sidewinder
thanks for the time and script that you wrote for me
its working very nice but wish it could act automatically it needs final user to specify the source folder . cant it be done by the program itself?
please read my last post i pot another script and another explain i think cuz of my bad English i explain the situation awful!!
ok guys i'm back again !
sometimes knowing a language is not enough and you should know how to ask !
Albert Einstein !!!

first of all sorry for my bad English its my teacher's fault !
i think i explained a simple question in a very hard or bad way and i made the situation very hard and so i did not got what i wanted at the first place
now forget about right click or any stupid idea that i said at the post #1( wish i could edit it)
now i try to explain my question in a easy to understand way


lets imagine we have a folder (named johns) and we want to copy all the files and folders(including sub folders)from johns to d:\backup
that's all that's what i want !! so we copy a batch file to johns folder and run it.. now batch should start the copying process .is it that hard for even old fashion Dos base batch file to do?
now the problem is that if i could put source folder name (johns) in batch script problem could be solved but cuz final program will use these batches and source folder name will be changed in a frequently time so i prefer that batch do this job for me
i mean batch Dir from the current folder and copy any including object to the destination
below you can see a simple batch that do this but instead of coping it moves the objects(i don't like this)

Quote
@echo off
cd
dir/s/b > filelist.txt
for /f "delims=" %%F in (filelist.txt) do move "%%F" "D:\backup"

any idea ?If it is the current directory you wish to copy, you can specify the current directory using a period (.):

For example, let us go with your example; let's say we have a folder Johns on C: drive; Let's say we are writing the batch file to run from within that folder (again, following your example scenario).

if we want to copy all files and folders from the current directory, we can use xcopy and the period

Code: [Select]xcopy . D:\backup /s /i

There is something of a complication: this doesn't necessarily refer to the folder the batch file is in. If you want to always refer to the folder that the batch is in (as opposed to the current directory of the command prompt session running the batch file) you can use this instead:

Code: [Select]xcopy %~dp0 D:\backup /s /i






my my my dear BC_Programmer thank you very much it worked like a charm
that was a simple but breath taking question ! you really help me thank again
i was really becoming disappointed and thought its simple but its not possible with dos !
i pressed thanks button and if there was 200 more buttons there i would have pressed them for you
=================

and other guys
Geek-9pm ---Sidewinder---Squashman----Salmon Trout
thank you all too you tried to teach me a lot

i have a little problem i forgot to ask how should this batch file create a folder in destination and rename it to current folder's name before copying files and folders from current directory to it
in another language
1-first create a folder in destination d:\backup\ and rename it to current folder's name= example johns(where my files and folders located now)
2- now copy files and folders from current directory(johns) fo d:\backup\ new destination folder (example=johns)
thanks

thanks its done above post has been solved thanks dear friends


Discussion

No Comment Found