cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1928
Views
10
Helpful
11
Replies

Multiple File Copy

mlitka
Level 2
Level 2

I am trying to copy multiple files from flash to a usb key. The issue isn't the media, its the proper command (if one exists). Is it possible to copy multiple files using one statment? For example:

copy flash: usbflash1:

It errors out and doesn't seem to like it.

If not possible natively, does anyone have a TCL script that can do this?

I am trying to come up with a solution to "image" a 2811 running CME (lots of config files, phone loads, etc.) by copying the flash onto a usb key.

Any advice would be appreciated.

Thanks,

Mike

11 Replies 11

Joe Clarke
Cisco Employee
Cisco Employee

See this thread where I gave a sample TCL script to iterate over all files:

http://forum.cisco.com/eforum/servlet/NetProf?page=netprof&forum=Network%20Infrastructure&topic=Network%20Management&CommCmd=MB%3Fcmd%3Dpass_through%26location%3Doutline%40%5E1%40%40.1ddcef70/2#selected_message

You can modify the code to perform a copy operation instead of just printing the file names out. For example:

set fileList [glob -directory flash: -nocomplain *]

foreach file $fileList {

copy flash:/$file usbflash1:/$file

}

Actually, try:

set fileList [glob -directory flash: -nocomplain *]

foreach file $fileList {

copy $file usbflash1:

}

You may also want to set "file prompt quiet" in the config first so that you're not prompted for each response.

WOW. Worked like a charm. Thanks for that quick solution!!

How do you include subdirectories and the files they contain?

You'll have to recurse by testing to see what type of file object you've encountered. So you'll need to test each object returned by glob with "file isdirectory". For each object that is a directory, you will need to perform the same glob operation on it.

OK. Now to tackle that :). An example would be awesome. :>

This is untested, but something like:

proc copyDir { dir dest } {

set fileList [glob -directory $dir -nocomplain *]

foreach file $fileList {

if { [file isdirectory $file] } {

copyDir $file $dest

} else {

copy $file $dest

}

}

}

copyDir flash: usbflash1:

Thanks. Tried to run this but nothing happened.

The key is the last line:

copyDir flash: usbflash1:

That sets thing in motion. The copyDir proc is just a function. If you don't execute it, nothing will happen. In the above example, "flash:" is the source and "usbflash1:" is the destination.

I found this post and had the exact same question. I copied the following to a notepad

set fileList [glob -directory flash: -nocomplain *]

foreach file $fileList {

copy $file usbflash1:

}

saved it as copy_files.tcl

Then TFTP to internal flash of router

I went into CLI and added the following

event manager applet copy_files

event none

then I trigger manually with event manager run copy_files

it says it's triggered but I must be doing something incorrectly.

This is not an EEM policy, but a tclsh script. You need to run it using tclsh from exec mode:

tclsh flash:/copy_files.tcl

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: