Can anyone help me with this program?

Example:
I have 100 images in one folder named "Photos". All the files are sequentially named.
I have subfolders under the "Photos" folder. Can a program be written wherein I am prompted to enter the file names, (for e.g. 01.jpg, 02.jpg, 03.jpg....) and then asked for the destination folder, and when I specify the subfolders name, all those files should be moved into that specific folder.

If, instead of entering each filename individually, it would be great if I could specify a numerical range.

Thank you for reading me out :sad: Appreciate all the help that I can get.

-Jason.

Hi, Jason,

I'm sorry; I don't know the code. But I do know how to move files.

I'm not sure why you are moving them individually. Using DOS, for example, you would move them in a bunch by using a wildcard, such as *.jpg, which would refer to "everything" that was a .jpg in that folder.

Using Windows, you would just drag the whole bunch of them at once. You could use EDIT and SELECT ALL, or else you could use your mouse with SHIFT for one contiguous bunch of files, or your mouse with CONTROL for your selection of individual files that were not necessarily together, but which had others you didn't want amongst them.

F2 is your shortcut key to rename any file or any highlighted group of files. If you press F2 and then press your HOME button, you ensure the file name is no longer highlighted, so you can modify an existing name, such as in changing "xJason" to "Jason". If you had a whole column of files highlighted and you pressed F2, you could rename them as a batch, incrementally:
Jason
Jason (1)
Jason (2)
Jason (3)
and so on. But that is renaming. I'm just mentioning it because it's pretty similar to the way you move files around.

File manipulation is vastly superior in XP than in Vista. In Vista it is slower, and you have to be careful to use the right mouse button or even to have both folders in question displayed side by side. Even so, it is still pretty straightforward in Vista.

From Windows 3.1 to Vista, however, you can always move, erase, rename, or copy any groups of files you wish from any location to any other location, without ever having to deal with files individually.

As well, you can also use freeware programs to do more sophisticated work; they include quite a few "rename" programs as well as programs which identify duplicate files in batches for you. They include, just as examples of a couple of good ones:
http://www.herve-thouzard.com/modules/wfsection/article.php?articleid=1
and
http://www.bigbangenterprises.de/en/doublekiller/

Perhaps you know all that (I'm sorry if I misinterpreted what you needed, in that case) and you are looking for exactly what you said. I would use a batch file in that case, but the good folk here know tons more than I do about making programs, so let's leave it to them to give you better information.

Thanx a lot for taking the time and trouble to reply to my post Groox. Really appreciate it. But like you mentioned, I know about all those conventional methods. Haven't yet checked the links that you have given. Will have a look at them as well.

My problem is that I am mostly dealing with 1000+ files, which are alphanumerically named. (for e.g. PIX0.000000.jpg.... PIX00.001580.jpg). I generate a full directory listing and keep for reference. I even tried making a batch file. But it looks something like this:
move PIX00.000000.jpg PIX_A1
move PIX00.000001.jpg PIX_A1
move PIX00.000002.jpg PIX_A1
move PIX00.000003.jpg PIX_A1
move PIX00.000004.jpg PIX_A1
move PIX00.000005.jpg PIX_A1
move PIX00.000006.jpg PIX_A2
move PIX00.000007.jpg PIX_A2
move PIX00.000008.jpg PIX_A2
move PIX00.000009.jpg PIX_A2
move PIX00.000010.jpg PIX_A2

Wherein, PIX_A1 & PIX_A2 are the subfolders. Doing this for a few files is okay, but when you are dealing with thousands of files, it becomes a headache. I checked the move command's help options. It mentions of a parameter wherein you can specify multiple files. Something like this:
move PIX00.000000.jpg, PIX00.000001.jpg, PIX00.000002.jpg PIX_A1

But for the life of me, I still can't get it right after numerous attempts. It would be great if I could get that at least. Life would be much more easier for me :)

Anyways Groox, thanx a lot for your time and patience.

Regards,
-Jason.

@westwing, you're welcome. Yes, I also put my .jpgs in directories of 1000 .jpgs each. That is about as large as I can go before my system gets pretty slow handling things.

I appreciate you are likely ahead of me rather than behind me on this. I'm still not precisely sure, however, which one of us is missing something—although I'm quite aware it might be me!

So, blissful in my ignorance, I will say that I would deal with the files as you show them in one of two ways.

— With a command prompt, I'd just move one where I wanted it, and then I'd press F3, which would re-display my command. Then I'd just change the vital integer and repeat.

I used to make extensive use of the wildcard * and also the specific-integer wildcard ??? (to indicate 3 digits, eg. black??? = blackcat, blackdog, blackhat). Therefore black— — — .jpg = black???.jpg, or black— — —.* = blackcat, blackdog, blackhat.[jpg, bmp, txt, whatever].

But that is still no good for more than a dozen or two commands. After much more than that, a person would go bonkers.

— But with the highlight and move GUI, I don't hesitate to move gigantic quantities of files that SEEM to me to be quite a bit like yours. I move 10 and 20 gigs with just one drag of the mouse, or one "copy to" or "move to" command. Hmmm. . . . But that's no good, huh?

I use multiple partitions for data files, so, for example, I might want to clean out Drive (Q) and reformat it, but it contains, say, 20 GBs of files. However, Drive (S) has room, so I just give the command once. My system is old and slow, so on XP that might take 15 or 20 minutes.

— Still attempting to focus in on your specific example, I would drag a highlight from (in your example) PIX00.000000.jpg down to PIX00.000005, and then I'd simply drag that multi-line highlight over and into PIX_A1. If the drag is from any one partition/drive to another, the function is Copy, not Move, by default; but it can be Move if so desired.

In that example there are just 5 files, but 1000 files would co-operate just as readily. Or, 876 of 984 files would likewise be an easy move. It looks like each one of your .jpgs has a unique name, so you wouldn't get into any "Replace File?" problems.

Oh well. My guess is that I am still a ways off the mark.

My own lists look like this:
Series 008
008000.jpg
008001.jpg
008002.jpg
008003.jpg
. . .
008999.jpg

Series 009
009000.jpg
009001.jpg
in which my pref is to number from 0 to 999. If a single file is misplaced during use, and that file is 043296.jpg, it is obvious that it belongs in Series 043 in which it is number 296.

In work in progress, I label my current series like this:
Series 421 (incl 421 816)
so that I can see at a glance that I am ready to recommence with new file 421817.

. . . This kind of manipulation does indeed work well with THE Rename, which I suggested above. All the various rename apps, however, require you to look things over before you do much the first time. The commands are clear and logical AFTER you figure things out; at first they seem confusing and not at all obvious.

Anyway, for what it's worth! And maybe someone else will show up anytime soon who sees exactly what you are seeking more clearly than I do, and can specify more exactly what info you need.

Good luck!

Hey Groox!

Thanx for all the time & work you are putting in.

What you say is perfectly right. I can mark the whole lot & move them into any particular sub-folder, however like I said, I am working with thousands of files and I maintain a listing in Excel of all the files in the folder and into which sub-folder they are to be transferred to. So it would be just easier for me if I could just copy and paste the whole list into a "move" command and specify the folder. That way I could do the whole lot in one batch file itself.

But I guess, I will just have to do some more research until I find a solution :( Until then, I am gonna go "bonkers" :'( like you mentioned.

Anyways, thanks a lot mate!

Regards,

-Jason.

Well, it sounds as though you'd want to use the conditional IF command, which is a DOS command still available to you in XP.

You could make a batch file using IF (and I would put in a PAUSE or two along the way, so you could check things in progress) using DOS. There is a very nice reference here:
http://www.computerhope.com/if.htm

That will be my last shot at this, as there is a point where help turns to hindrance, and I don't want to step across that line.

The only other detail I forgot to mention was that I maintain a few directories called Empty Boxes [as (H) Empty Boxes] in which I have skeleton hierarchies of empty folders ready for future requirements. It is faster to create these empty files using my DOS prompt than to do the job individually as the individual need arises.

Good luck, and, when you have the solution, please post it. My brain has the fuzzies, and I'm interested to see what you end up doing. :)

Hey Groox!

Sorry for the delay in replying. Wasn't keeping well.

Just read your post. Will go thru it and reply.

Thanks a lot!

-Jason.

Hi, I am running into the same problem. Cannot seem to be able to move multiple files using the move DOS command. Works for 1 file but not for 2 or more.

move file1.jpg, file2.jpg activities

I get a synthax error.
Please help! I have a lot of files to move!

Thanks a lot,

Ge

Geraldine,

First of all, please read the posting rules. I see you are a new member and probably did not know, but we do not use other peoples post to post our own problem. You need to start your own thread and we will help you where we can. It's all about raising the dead, which creeps us out on this side.

To answer your question, below is some code which will first create a folder if it does not exist, then load a picture so you can be sure that it is the correct picture loaded, then saves it under the new folder created with whatever name you select. Play around with this to suit your needs. -

1st add a module to your app -
Under references, reference Microsoft Scripting Runtime

Option Explicit

Public Function SavePictureToFile(picPhoto As Image, txtNumber As TextBox, strPhotoMake As String)

Dim nImageSize As Long, Picsize As Long
Dim hFile As Long
Dim Filename As String, strNumber As String, strName As String, strSave As String

strNumber = txtNumber.Text
strName = strPhotoMake

strSave = strNumber & " " & strName

Filename = "\\" & frmMainMenu.txtServerIp.Text & "\cserver\" & strNumber & "\" & strName & ".dat"

'save the picture portion as the first entry
'in the "combined file"
SavePicture picPhoto.Picture, Filename
    
'Open the combined file for append in order to
'add the text to file
hFile = FreeFile
   
Open Filename For Binary As #hFile
         
'Retrieve the size of the image into a
'variable for later use, then append the
'text into the same file.
nImageSize = LOF(hFile)

'prg1.Max = nImageSize

Seek #hFile, nImageSize + 1
Put #hFile, , strSave

'The file now contains both the image
'and text file. As a final step, we
'save the length of image retrieved
'above as the last item in the file.

Seek #hFile, LOF(hFile)
Put #hFile, LOF(hFile) + 1, nImageSize

Close #hFile
End Function

Public Function LoadPictureFromFile(txtNumber As TextBox, strPhotoMake As String, imgLoaded As Image)

Dim nImageSize As Long
Dim hFile As Long
Dim hFileOut As Long
Dim PicData() As Byte
Dim Filename As String, strNumber As String, strTextOutput As String, strLoad As String
Dim sTmpPix

strNumber = txtNumber.Text

strLoad = strPhotoMake

Filename = "\\" & frmMainMenu.txtServerIp.Text & "\cserver\" & strNumber & "\" & strLoad & ".dat"
sTmpPix = "\\" & frmMainMenu.txtServerIp.Text & "\cserver\Temp.jpg"

'First step in the extraction process is to
'obtain the length of image portion saved
'as the last item in the file.
hFile = FreeFile

Open Filename For Binary As #hFile
   
'move to the LOF - 3 and load the
'saved image size
Seek #hFile, LOF(hFile) - 3
Get #hFile, , nImageSize
      
'with the image size, create a byte array
'large enough to accommodate the image
ReDim PicData(0 To nImageSize - 1) As Byte
    
'and load the image data, repositioning the
'file pointer to the beginning first
Seek #hFile, 1
Get #hFile, , PicData()
         
'write the pix to a temporary file in
'order to use the LoadPicture method.
hFileOut = FreeFile

Open sTmpPix For Binary As #hFileOut
Put #hFileOut, , PicData()
Close #hFileOut
    
'load the text portion to the textbox. The
'text begins immediately after the image, and
'extends for the file length minus the trailing
'4 bytes for the Long that stored the image size.
Seek #hFile, nImageSize + 1
strTextOutput = Input(LOF(hFile) - nImageSize - 4, hFile)
      
Close #hFile
   
'Load the saved image from the tmp file
'and kill it
imgLoaded = LoadPicture(sTmpPix)
Kill sTmpPix
End Function

Public Function CreateFolder(txtFolderNumber As TextBox)

Dim NewFolder
Dim NewFlag As Boolean
Dim strMessage As String, strPathName As String, strFolderName As String

NewFlag = False
strPathName = "C:\" 'Set the path to where the new folder will be created.

strFolderName = strPathName & txtFolderNumber.Text 'The textbox will return the name of
'the folder that you are about to create, or if it exist, which you will use to copy to.

Set NewFolder = CreateObject("Scripting.FileSystemObject")

If NewFolder.FolderExists(strFolderName) = False Then 'If folder does not already exist,
    'create it.
    NewFolder.CreateFolder (strFolderName)
    NewFlag = True
    
    MsgBox "a New folder named " & strFolderName & " has been created in " & strPathName & ".", vbOKOnly + vbInformation, "New Folder Created"
        Else
    'Add code here if you need to do anything else when the folder already exist
End If
End Function

At form level at an image control and 3 command buttons, 1 Textbox.

Add the code as follow -

Private Sub Command2_Click()

SavePictureToFile Image1, Text1, "Geraldine1"
End Sub

Private Sub Command1_Click()

CreateFolder Text1
End Sub

Private Sub Command3_Click()

LoadPictureFromFile Text1, "Geraldine1", Image1
End Sub

I hope this helps...

This article has been dead for over six months. Start a new discussion instead.