Solved

Copying folder command issues

Posted on 2013-10-28
7
304 Views
Last Modified: 2013-11-06
I'm racking my brain on this.  I have a scanner that dumps it's scans into a folder.  In that folder it creates a folder structure of a sequential numbered batch and then in that folder another folder named "1" with the scans with in it.  So example two folders would be
C:\sample\"5"\1\scan1.jpg
C:\sample\"6"\1\scan2.jpg
Now I need to move the folder named "1" from "sample" to a network location to be sucked up into a document management system for indexing/archiving purposes.  For the end users I was thinking a bat file they could click to run that would copy all of the "1" folders and then delete the source including the sequentially numbered folder as well leaving just an empty "sample" folder.  Halp?
0
Comment
Question by:leshad82
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 9

Expert Comment

by:jsdray
ID: 39605851
May want to setup a scheduled task on the server/computer that receives the files.  Use robocopy *.jpg with the /mov option...  and then there's nothing to delete
0
 
LVL 9

Expert Comment

by:jsdray
ID: 39605860
robocopy <Source> <Destination> [<File>[ ...]] [<Options>]

Options      
/s
Copies subdirectories. Note that this option excludes empty directories.
/e
Copies subdirectories. Note that this option includes empty directories. For additional information, see Remarks.
/lev:<N>
Copies only the top N levels of the source directory tree.
/z
Copies files in Restart mode.
/b
Copies files in Backup mode.
/zb
Uses Restart mode. If access is denied, this option uses Backup mode.
/efsraw
Copies all encrypted files in EFS RAW mode.
/copy:<CopyFlags>
Specifies the file properties to be copied. The following are the valid values for this option:
D Data
A Attributes
T Time stamps
S NTFS access control list (ACL)
O Owner information
U Auditing information
The default value for CopyFlags is DAT (data, attributes, and time stamps).
/dcopy:T
Copies directory time stamps.
/sec
Copies files with security (equivalent to /copy:DAT).
/copyall
Copies all file information (equivalent to /copy:DATSOU).
/nocopy
Copies no file information (useful with /purge).
/secfix
Fixes file security on all files, even skipped ones.
/timfix
Fixes file times on all files, even skipped ones.
/purge
Deletes destination files and directories that no longer exist in the source. For additional information, see Remarks.
/mir
Mirrors a directory tree (equivalent to /e plus /purge). For additional information, see Remarks.
/mov
Moves files, and deletes them from the source after they are copied.
/move
Moves files and directories, and deletes them from the source after they are copied.
/a+:[RASHCNET]
Adds the specified attributes to copied files.
/a-:[RASHCNET]
Removes the specified attributes from copied files.
/create
Creates a directory tree and zero-length files only.
/fat
Creates destination files by using 8.3 character-length FAT file names only.
/256
Turns off support for very long paths (longer than 256 characters).
/mon:<N>
Monitors the source, and runs again when more than N changes are detected.
/mot:<M>
Monitors source, and runs again in M minutes if changes are detected.
/MT[:N]
Creates multi-threaded copies with N threads. N must be an integer between 1 and 128. The default value for N is 8.
The /MT parameter cannot be used with the /IPG and /EFSRAW parameters.
Redirect output using /LOG option for better performance.
noteNote
The /MT parameter applies to Windows Server 2008 R2 and Windows 7.
/rh:hhmm-hhmm
Specifies run times when new copies may be started.
/pf
Checks run times on a per-file (not per-pass) basis.
/ipg:n
Specifies the inter-packet gap to free bandwidth on slow lines.
/sl
Copies the symbolic link instead of the target.
0
 

Author Comment

by:leshad82
ID: 39605877
It has to be done on demand.  The end users need to move and index/archive the scans right away after scanning.  I don't need to delete but they will be making hundreds of these .jpgs daily so space may become an issue rather quickly as the source machine is just a PC.  We will have the images in the document management system so retention isn't an issue.  I was also hoping to keep them in the "1" folder as it will act as a batch which will help as they are indexed at the "batch" level.  Cleaner for the end user.  I know of a few ways to just copy the folder but I keep getting stuck at the fact the sequential number changes with each batch and not sure how I can wild card it or not.
0
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 
LVL 9

Expert Comment

by:jsdray
ID: 39608285
robocopy has the include sub-directory option /s so you don't have to worry about the sequential number change.

Could still be done on demand, but I was thinking more like a continuous loop so they wouldn't have to do anything....
0
 

Accepted Solution

by:
leshad82 earned 0 total points
ID: 39617678
I answered my own question with the following powershell command.

$src = "source\folder"
$dest = "destination\folder"
$num=1

Get-ChildItem -Path $src -Recurse -include "1" | ForEach-Object {

    $nextName = Join-Path -Path $dest -ChildPath $_.name

    while(Test-Path -Path $nextName)
    {
       $nextName = Join-Path $dest ($_.BaseName + "_$num" + $_.Extension)    
       $num+=1  
    }

    $_ | Move-Item -Destination $nextName
}

This essentially searches the folder where the scans go for folders called 1 in every subfolder then moves them to the destination and if one already exists adds _1, _2 etc as needed.
0
 

Author Comment

by:leshad82
ID: 39617684
I concur
0
 

Author Closing Comment

by:leshad82
ID: 39626861
Out of the comments given none really designed the solution I was looking for.
0

Featured Post

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: I have always been a big fan of Windows but my liking towards it is slowly being eroded by the variety of other Applications that I encounter, when I browse the Web. Most of the software available is free and maybe Open Source too. …
This article covers how to install the Microsoft Windows Operating System (OS). What is covered in this article:  > Different Versions and Editions of the Windows OS  > Upgrading versus Fresh Installation of the OS           - Steps to take pr…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question