Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

Multiple File Copy

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
Cisco Employee

Re: Multiple File Copy

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

}

Cisco Employee

Re: Multiple File Copy

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.

New Member

Re: Multiple File Copy

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

New Member

Re: Multiple File Copy

How do you include subdirectories and the files they contain?

Cisco Employee

Re: Multiple File Copy

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.

New Member

Re: Multiple File Copy

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

Cisco Employee

Re: Multiple File Copy

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:

New Member

Re: Multiple File Copy

Thanks. Tried to run this but nothing happened.

Cisco Employee

Re: Multiple File Copy

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.

New Member

Re: Multiple File Copy

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.

Cisco Employee

Re: Multiple File Copy

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

714
Views
10
Helpful
11
Replies