Jump to content
Server Maintenance This Week. ×

Move/copy File Plug in


This topic is 6995 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Scenario

I want the user to be able to copy/move a file from one location to another without having to type in the file extention in the destination path. ie. .pdf .doc etc as they keep cocking it up and are then unable to open the file.

Ive looked at various plug ins for file manipulation and they do not seem to offer a script that identifies a file type.

Is ther a plugin that can do this or is there a way around it?

Link to comment
Share on other sites

Thanks steve the problem with troi and the others ive looked at is you have to assign a file name to the copied or moved file, when prompting the user to enter the filename they dont understand which file extension to list at the end of the filename, then they complain that they then cant open the file when it has been moved.

Link to comment
Share on other sites

You're right, users are generally clueless. Have you thought about using a temporary file to create the output (known only to you), then get a filename from the user without an extension if necesssary, and then moving an renaming the temp file?

Steve

Link to comment
Share on other sites

Hi stefanshotton,

You can use the TroiFile plugin to get a directory listing.

Write a script that gets the list of files in the directory and compares each to the filename (excluding the extension) that the user entered (as the copy-from file). When a match is found, you extract the file's extension for the copy/move.

If a match is not found within the list of files in the directory, your script presents a "File Not Found" message to the user.

To accomplish this, you need to have your script loop through the list of filenames returned by Troi's ListDirectory function (it might be named something else, please refer to the Troi manual). Your script extracts one file at a time to a temporary field and compares it (minus its extension...use the middle function in conjunction with the position and patterncount functions (keep in mind that you always want to get the last "."...that's why patterncount is needed)) to the filename (again this is the copy-from filename, rather than the copy-to filename) typed in (or selected) by your user.

When a match is found, you can safely copy the file to the new location (again, use the middle function to extract the original file's extension) and exit your loop. Exit your loop and display a "File Not Found" message to your user if you run out of files to check in the directory.

I'm sorry for not showing you how to code this, but I've just gotten off a 12 1/2 hour work day and need sleep badly. I'm hoping one of the posters above will be able to help now that I've explained what needs to be done.

To confirm that it can be done, I'm using exactly the method above to accomplish pretty much what you're trying to achieve (in my case, files are renamed and copied to new folders automatically...and the copied files retain the extensions of the original files).

Hope this helps!

Kind Regards,

Cobra

Link to comment
Share on other sites

This topic is 6995 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.