473,396 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to replicate file/s "x" times in a directory all with dynamic values at runtime?

Hello,

I am trying to create a program that would replicate different selected files "x" times into a specified directory and save them with filename indexes. Then after create a log list of the successfully copied files via LogListBtn click ( maybe saving the text file in the C: root)

ex.
a. Help.txt ( copy 3x ), Report.xls ( copy 2x )

When they are saved in a specified directory they should look like:

Help(1).txt
Help(2).txt
Help(3).txt
Report(1).xls
Report(2).xls

By the way this is my code in adding the selected files by drag dropping them in a FRAME, then creating 2 textboxes in 1 row where:

Text1 ( as textbox ) - where full path and filename is displayed
CopyTimes ( as textbox ) - number entry for x times a file is to be copied

Expand|Select|Wrap|Line Numbers
  1. Private Sub DropArea_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
  2. Dim i As Integer
  3. Dim dCount As Integer
  4.  
  5.       On Error GoTo No_File_info
  6.       i = Text1.count - 1
  7.  
  8.       For dCount = 1 To Data.Files.count
  9.  
  10.          Load Text1(i + dCount)
  11.          With Text1(i + dCount)
  12.             .Top = Text1(i + dCount - 1).Top + Text1(0).Height
  13.             .Text = (Data.Files.Item(dCount))
  14.             .Visible = True
  15.  
  16.          End With
  17.  
  18.          Load CopyTimes(i + dCount)
  19.          With CopyTimes(i + dCount)
  20.             .Top = CopyTimes(i + dCount - 1).Top + CopyTimes(0).Height
  21.             '.Text = i + dCount
  22.             .Visible = True
  23.          End With
  24.  
  25.       Next
  26.       FrameSlide.Height = Text1.count * Text1(0).Height
  27.       If FrameSlide.Height > FrameFix.Height Then
  28.          With VScrollFiles
  29.             .Max = (FrameSlide.Height - FrameFix.Height) / 10
  30.             .SmallChange = 200
  31.             .LargeChange = FrameFix.Height / 10
  32.             .Visible = True
  33.          End With
  34.       Else
  35.          VScrollFiles.Visible = False
  36.       End If
  37. Exit Sub
  38. No_File_info:
  39.    MsgBox "No File name from Explorer"
  40. End Sub
  41.  
I can't seem to find a code on how to replicate these files to my destination directory which is at SaveTo ( as textbox ).


This is the full code of the program:
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Dim fselectIDX As Integer
  3.  
  4. Private Sub CopyTimes_KeyPress(Index As Integer, KeyAscii As Integer)
  5. If Not (KeyAscii = vbKeyBack) Then
  6.     If Not Chr(KeyAscii) Like "#" Then
  7.     KeyAscii = 0
  8.     MsgBox ("Number entry only.")
  9.     End If
  10. End If
  11. End Sub
  12.  
  13. Private Sub Form_Load()
  14.     DropArea.OLEDropMode = 1      '§ manual
  15.     Text1(0).Top = -Text1(0).Height + 180
  16.     CopyTimes(0).Top = -CopyTimes(0).Height + 180
  17.  
  18.     With VScrollFiles
  19.       .Visible = False
  20.       .Min = -30
  21.    End With
  22.  
  23. End Sub
  24.  
  25.  
  26. Private Sub Dir1_Click()
  27. SaveTo.Text = Dir1.Path
  28. End Sub
  29.  
  30. Private Sub Drive1_Change()
  31. Dir1.Path = Drive1.Drive
  32. End Sub
  33.  
  34. Private Sub OpenWEBtn_Click()
  35.     Dim Det As Long
  36.     Det = Shell("explorer.exe /e, C:\", vbNormalFocus)
  37. End Sub
  38.  
  39. Private Sub DropArea_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
  40. Dim i As Integer
  41. Dim dCount As Integer
  42.  
  43.       On Error GoTo No_File_info
  44.       i = Text1.count - 1
  45.  
  46.       For dCount = 1 To Data.Files.count
  47.  
  48.          Load Text1(i + dCount)
  49.          With Text1(i + dCount)
  50.             .Top = Text1(i + dCount - 1).Top + Text1(0).Height
  51.             .Text = (Data.Files.Item(dCount))
  52.             .Visible = True
  53.  
  54.          End With
  55.  
  56.          Load CopyTimes(i + dCount)
  57.          With CopyTimes(i + dCount)
  58.             .Top = CopyTimes(i + dCount - 1).Top + CopyTimes(0).Height
  59.             '.Text = i + dCount
  60.             .Visible = True
  61.          End With
  62.  
  63.  
  64.       Next
  65.       FrameSlide.Height = Text1.count * Text1(0).Height
  66.       If FrameSlide.Height > FrameFix.Height Then
  67.          With VScrollFiles
  68.             .Max = (FrameSlide.Height - FrameFix.Height) / 10
  69.             .SmallChange = 200
  70.             .LargeChange = FrameFix.Height / 10
  71.             .Visible = True
  72.          End With
  73.       Else
  74.          VScrollFiles.Visible = False
  75.       End If
  76. Exit Sub
  77. No_File_info:
  78.    MsgBox "No File name from Explorer"
  79. End Sub
  80.  
  81.  
  82. Private Sub Text1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
  83.    fselectIDX = Index
  84.    If Button = vbKeyLButton Then PopupMenu PUMenu_Files
  85. End Sub
  86. '§ =============================================
  87. '§ MENUS
  88. '§ =============================================
  89.  
  90. Private Sub PUMenu_DeleteFile_Click()
  91. Dim BOXidx As Integer
  92.    If fselectIDX <> Text1.count Then '§ if not last box
  93.       For BOXidx = fselectIDX To Text1.count - 2
  94.          Text1(BOXidx).Text = Text1(BOXidx + 1).Text
  95.          CopyTimes(BOXidx).Text = CopyTimes(BOXidx + 1).Text
  96.       Next
  97.       Unload Text1(Text1.count - 1)
  98.       Unload CopyTimes(CopyTimes.count - 1)
  99.    Else '§ if last box
  100.       Unload Text1(fselectIDX)
  101.       Unload CopyTimes(fselectIDX)
  102.    End If
  103.    Call Calc_FrameSlide_Height
  104. End Sub
  105.  
  106. Private Sub VScrollFiles_Change()
  107. FrameSlide.Top = -VScrollFiles.Value * 10
  108. End Sub
  109.  
  110. '§ =============================================
  111. '§ FUNCTIONS
  112. '§ =============================================
  113.  
  114. Private Function Calc_FrameSlide_Height()
  115.    FrameSlide.Height = Text1.count * Text1(0).Height
  116.    If FrameSlide.Height > FrameFix.Height Then
  117.       With VScrollFiles
  118.          .Max = (FrameSlide.Height - FrameFix.Height) / 10
  119.          .SmallChange = 200
  120.          .LargeChange = FrameFix.Height / 10
  121.          .Visible = True
  122.       End With
  123.    Else
  124.       VScrollFiles.Visible = False
  125.    End If
  126. End Function
  127.  
Tool UI:



Buttons not working yet are:
a. Replicate Button
- should be able to replicate selected file/s into destination directory "x" times
b. Log List Button
- should be able to create a text file saved at C: root drive with name LogList.txt with format:

1. file(1).txt
2. file(2).txt
3. file(3).txt
4. file(1).xls
5. file(2).xls
.......



Please help.
Thanks!
Jan 4 '11 #1
1 1317
correction for the Tool UI ( I removed the checkboxes already).

I hope somebody could help me.

Thank You.
Jan 4 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

43
by: steve | last post by:
I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)? The path in include is...
0
by: Jan | last post by:
I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the...
11
by: brian.newman | last post by:
I'm trying to use a layer inside a form to hide/reveal a part of the form, but my code doesn't seem to be working and I need some help debugging it. I'm not getting an error which has made it...
3
by: | last post by:
I am working on a web/webservice application that has a service layer. Most service methods will perform an access-check before executing. This check uses the IPrincipal credentials available in...
21
by: nicholas | last post by:
Although in my web.config I have <customErrors mode="off" /> I still get no detailed errors. How comes ? THX This is what I get: Server Error in '/mywebfolder'Application.
5
by: Savas Ates | last post by:
I have a web application It works well in my local folder.. When i upload it to my web server i got To enable the details of this specific error message to be viewable on remote machines,...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
15
denny1824
by: denny1824 | last post by:
I have a working website. I copied all the files to a new folder in inetpub/wwwroot and then set that folder as a Virtual Directory in IIS. I try going to that site from the new folder and i am...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.