Getting Filename without Path in a CFC

Hi All,
I'm attempting to use a CFC/Event Gateway to get the filename of a file that has landed in a directory.
What I'm getting instead is the full path with the filename.
<cfcomponent>
<cffunction name="onAdd" access="public" returntype="void" output="false">
<cfargument name="CFEvent" type="struct" required="true">
<cfset var data = arguments.CFEvent.data>
<cfset var filename = arguments.CFEvent.data.filename>
</cffunction>
</cfcomponent>
I know that the above code isn't complete, but I think it's what 'counts' here.
The value that I'm getting back for the 'filename' variable is similar to this:
C:\WebSite\Some_Directory\Another_Directory\filename.ext
What I want is just the filename  (filename.ext) part of that line.
It appears that arguments.CFEvent.data.filename doesnt do it, and I've tried all kinds of combinations like  'filename', 'serverfile.filename', 'data.filename' and so on, but I must just be missing it.
I found a workaround for what I'm trying to do with the CFC,  but it would be a lot easier if I just knew what I need to use in the code to just pull the filename of the file that was dropped into the directory.  (Using the DirectoryWatcher)
If anyone can help out with how to do this,  it would be appreciated
I've been at this for ten hours and feel like Captain Noob right about now.
Thanks!
CFML_MANIAC

CFML_MANIAC wrote:
The value that I'm getting back for the 'filename' variable is similar to this:
C:\WebSite\Some_Directory\Another_Directory\filename.ext
What I want is just the filename  (filename.ext) part of that line.
It appears that arguments.CFEvent.data.filename doesnt do it, and I've tried all kinds of combinations like  'filename', 'serverfile.filename', 'data.filename' and so on, but I must just be missing it.
You're missing nothing. It is simply that ColdFusion stores the file in the CFEvent struct as an absolute path. It makes sense, of course. The functionality is directory-watcher, so one should be able to derive information about the directory structure of the added file.

Similar Messages

  • Email response: Get filename without extension

    I've got the following workflow setup:
    On subscription:
    - Encode file to lowres h264 quicktime movie
    - Place encoded file on webserver(make no new asset)
    - Send email with: Video ready review on http://localhost/[[File Name]]
    This workflow works when encoding an original quicktime movie. But when a mpeg is being encoded the link in the email says video.mpg. Instead of video.mov.
    Is there a way to only get the filename without the extension so I can put this down in my mail: http://localhost/[[File Name]].mov
    Another thing I ran into is that if the filename contains spaces the link is not being put down nice in the mail. I there a way to use html tags?
    Message was edited by: StefSOFT

    Why not just use the builtin method.  No ned to customize for this.
    set wshell = createobject("WScript.Shell")
    CurPath = WShell.Currentdirectory
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set objFolder = fso.GetFolder(curpath)
    Set files = objFolder.Files
    For each fileIdx In files
    WScript.Echo fileidx.name
    Wscript.Echo Replace(fileIdx.Name,"." & fso.GetExtensionName(fileIdx.Path),"")
    Next
    You just need one line.
    FYI
    I do not understand the use of ByVal when that is the default for VBScript and nearly all languages. 
    ByRef can be used to allow a function to set a value and have it set the value in the caller. 
    ByVal and ByRef will not affect a true object like the fso.  Objects are alway passed by reference in VB languages.
    ¯\_(ツ)_/¯

  • FileUpload get filename and PATH?

    Hi everybody,
    is there a chance to get also the path from where to upload a file using the fileupload-UI?
    Thanks a lot
    Regards Mario

    Mario,
    No, this is not possible due to security restrictions imposed by browsers
    VS

  • How do I get the full path and filename of the current document?

    I'm writing a format plug-in. How do I obtain the full path and filename of the current image (document) from within my plug-in? Any help would be greatly appreciated!

    I actually just figured this out. For anyone else who would like to know, check out the propetizer sample code in the photoshop sdk. It makes a "filter" plug-in that just spits out all the properties of the document you could ever want to know about. The function I used to get the full path and filename of the current document is PIGetDocumentName(). I hope this helps someone eventually...

  • Get the absolute path and filename of the file from the command line

    Hi,
    when we run the class we give the command
    java <filename>
    How can I capture the filename given above and get its absolute path inside the
    public static void main(String [] args){}
    args[0] gives me the command line argument after the filename. How do I capture the filename itself from the command line argument and also get that files absolute path
    Thanks

    I don't know of any way to capture the java command input, but there are ways to find out where the application is being run from. (the "absolute path")
    http://forum.java.sun.com/thread.jsp?forum=31&thread=335394

  • How to get FILENAME from FILE PATH

    does anyone know how to get filename from a file path for example
    FILE PATH: C:\Project\uploadbean\web\uploads\Button.txt
    returns
    FILENAME: Button.txt

    @BalusC
    ust for a reference cause i'm new in JSP This has nothing to do with JSP, but with basic knowledge of an essential API. I have given you the link to the File API. Are you saying that you refused to read the API documentation, which clearly explains you how to use the File and shows which methods are all available to you undereach the straightforward getName() method, and expecting that the others may chew the answers for you? Loser.

  • How can I get a filename without the file extension?

    I using a JFileChooser to select and read a file. Now I want to get the filename without the file extension
    JFileChooser j = new JFileChooser;
    String file = j.getSelectedFile.getName();
    At the moment I get this result "file.dat". I need only the filename.....
    Thank you
    Thomas

    It's quite that.
    Here is the code to do that (and the method to get only the extension):
         public String getFileName(String text) {
              int ind = text.lastIndexOf(".");
              if(0<ind && ind<(text.length()-1)) {
                   return text.substring(0, ind);
              return(null);
         public String getFileExtension(String text) {
              int ind = text.lastIndexOf(".");
              if(0<ind && ind<(text.length()-1)) {
                   return text.substring(ind+1).toLowerCase();
              return(null);
         }(I used 0<ind instead of ind>0 because with the code formatting there is a bug with > )
    I hope this helps,
    Denis

  • How Do I get a File Path from a FileName?

    Hi there,
    I was wondering how do i get a file path(i.e) directory only from a file name.
    Say i got a file called "C:\Test.txt" is there a method in java that will allow me to only get "C:\"?
    I've tried getPath(), getAbsolutePath() and they all return the directory and the file itself.
    Please Help
    James

    String path = file.getPath();
    String name = file.getName();
    int i=0;
    for(i=0; i< (path.length()-name.lenth() ); i++){
    String temp = path.substring(i, i+name.length());
    if(temp.equals(name) break;
    return path.substring(0,i);

  • Trying to add filename and path in footer of Word doc and it only lets me "Convert to PDF"?

    I am running MS Office 03 and just installed Acrobat 9.0 Pro. When I try to insert the Filename and Path from the insert option of the footer properties, it only gives me the option to "Convert to PDF". I don't know why it's doing this, but it started after the install of Acrobat 9.0. What should I do?

      To get the path ... event.target.path;
    To get the file name .... event.target.documentFileName;

  • Filename and path sizes and characters

    I am failing to load 4000+ tracks to my Ipod from my XP machine using Itunes 7.50.0.20. This is an Ipod Clickwheel 20GB. I want to load 17.86GB in the now empty Ipod. However it gets so far then stops saying there is not enough space.
    I wonder if am I getting the wrong message?
    Some of my tracks have very long filenames/paths e.g 124 charactere filenames and 213 character paths. I also have some filenames with " (double quote) in.
    Could this be the reason?
    If so what characters must I avoid and what size should the filename and paths be limited to?

    Filenames and paths are irrelevant. They are renamed on the iPod anyway.
    20 GB is not really 20. It is a rounded number all HD manufacturers use. Plus you lose some space due to formatting and the iPod software. There is also meta data for the songs which takes some space.

  • How to get the file path in adf application

    hii all,
    i have a txt file that i am using in my adf application,
    i am passing this txt file through a File Reader, for which i have to mention the file path.
    The file is in web-content and when i am hard coding the complete file path i.e C:/JDeveloper/myApp/ViewController/public_html/log.txt
    the application is working fine when run on integrated weblogic server.
    My requirement is to access this file without giving the static file path, as in case i have to use this application on any other machine..
    for that how to mention the file path-
    i tried using FacesContext to get the context path :-
    FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath();
    which gives me
    \myApp-ViewController-context-root
    after appending public_html\log.txt
    I am using the following path to access the file :-
    \myApp-ViewController-context-root\public_html\log.txt
    again i am getting the java.io.FileNotFoundException
    Does anyone know how to use file from inside the web-content without giving the complete path..???
    Thanks

    Hi,
    If you put your file under public_html folder, you can use this code to access the file:
    For example file is : log.txt
    FacesContext.getCurrentInstance().getExternalContext().getRealPath('/log.txt').toString().trim();
    Thanks.
    - LSR

  • How to get the complete path of the file that is selected using FormFile

    i m working on struts..
    i hv used FormFile like
    <html:file property="xsdpath" value="Browse" />
    need to get the whole path that i will select using browse button
    for example d:\foldername\filename.java
    but FormFile Api has a method getFileName(); which returns the filename, for getting the absolute path wat has to be done.
    please reply bak soon
    thanks in advance

    here i use formfile <html:file> just to allow the
    user to select a xml file .
    so i need to get the whole path of the selectedfile
    to parse the xml file.No you dont.
    You would definitely benefit from further reading on
    file upload.
    <html:file> tag renders an HTML <input> element of
    type file.
    When a user uploads a file, this file is sent as a
    stream of data, which a program (jsp/servlet) on the
    server, reads and stores the data back in the form
    of a file on the server.
    Any server program that needs to parse the file,
    should do so on the file stored on the server.
    There's no point in knowing the absolute path of the
    file on the client machine. If a server program can
    parse a file on the client machine, why upload the
    file in first case ? Get the drift ?
    i also want to show my user the path he hadselected.
    If you have such a requirement, then yes.
    But it sounds weird to me. If you see my response
    above, you will realize that the server has a copy of
    the client's file uploaded and then parsed. What if
    the client has changed his file after upload ?
    cheers,
    ram.I also have a requirement to get the whole filepath of the file selected and place this information into a table. From FormFile I can only retreive the absolute filename
    Any suggestions would be helpful.
    Thanks, dam

  • How to get the file path from HTML input form in Firefox3

    In IE7 (and probably all famous browsers, including old Firefox 2), if we submit a file like 'C:\folder1\folder2\folder3\filename' it works properly and gives the full path to the file and the filename.
    In Firefox 3, it returns only 'filename', because of their new 'security feature' to truncate the path, as explained in Firefox bug tracking system (https://bugzilla.mozilla.org/show_bug.cgi?id=143220)
    I have no clue how to overcome this 'new feature'.
    Can anyone help to find a single solution to get the file path both on Firefox 3 and IE7?
    Thanks in advance....

    Doubleposted and ignored any previous answer: [http://forums.sun.com/thread.jspa?threadID=5342405]. Don't do that. It's rude.
    Regarding to your "problem": why do you need the file path?

  • How to get the file path from HTML input form in Firefox 3...

    In IE7 (and probably all famous browsers, including old Firefox 2), if we submit a file like 'C:\folder1\folder2\folder3\filename' it works properly and gives the full path to the file and the filename.
    In Firefox 3, it returns only 'filename', because of their new 'security feature' to truncate the path, as explained in Firefox bug tracking system (https://bugzilla.mozilla.org/show_bug.cgi?id=143220)
    I have no clue how to overcome this 'new feature' because it causes all upload forms in my webapp to stop working on Firefox 3.
    Can anyone help to find a single solution to get the file path both on Firefox 3 and IE7?
    Thanks in advance....

    As you're posting this in the JSF forum and looking at your [previous topic|http://forums.sun.com/thread.jspa?threadID=5342365], I assume that you're using Tomahawk's t:inputFileUpload. In this case, just use UploadedFile#getInputStream(). You may find this article useful: [http://balusc.blogspot.com/2008/02/uploading-files-with-jsf.html].
    By the way, are you lazy or just dumb? You wasted one week to this! I've posted the aforementioned article one week ago. How did you stuck?

  • Given filename or path contains Unicode or double-byte characters.Retry using ASCII characters for filename and path What does this mean? it happen when I publish an OAM

    Given file name or path contains Unicode or double-byte characters. Retry using ASCII characters for filename and path
    What does this mean? It is happening when I try to publish an OAM for Dreamweaver.
    Also: How can I specify the browser in Edge Animate? It is just going wherever. Are there no Preferences for Edge Animate?
    BTW. Just call it Edge. Seriously. Do you call it Illustrator Draw? Photoshop Retouching?

    No, my file name is mainContent.oam
    My project name is mainContent.an
    This error happens when I try to import into Dreamweaver. Sorry, I wasn't clear on that earlier.
    I thought maybe it was because I had saved my image as a png. So re-saved as a svg, still get the error.
    DO I have a setting is Dreamweaver CC that is wrong? Should I try this in Dreamweaver CS6? I might try that next.
    Why is this program so difficult? I know Flash. I know After Effects. I can work the timeline part just great. It's always in the export that I have problems.
    On a MacPro, 10.7.
    Are you an Adobe person or just a nice helper?

Maybe you are looking for

  • How could I set a fixed window for all resulution?

    because I design the website in MAC when I transfer to PC it change shape how could I set a fixed size window for all resulution?

  • Chat window stuck in minimize mode

    I have a chat window that is stuck in minimize mode, unable to exit the window. Red window appears when receiving messages from buddy but cannot maximize the window. I have restarted my computer, force quit my iChat and every time I sign on that wind

  • OIM 11g - Time zone Issue

    Hi, We have a OIM 11g instance running at a central location. (PST). Our implementation is for a Global Company having offices at multiple locations ( Say Germany, US , India and Japan ). So, the users should be provisioned / terminated only on the l

  • Smart Collection by Collection Sets?

    Hey all, Quick question on creating a Smart Collection within a Collection Set: Here's the deal: I have a collection set.  In it, I have a collection of about 358 photos.  From there, I rated the photos.  I then tried to create a Smart Collection fro

  • HT4623 Problem in updating to ios7 through itunes

    I am connecting my ipad and it is not detecting, it tells to restore and update to ios 7, when i am updating through itunes, it starts to download but when the internet goes all the data is gone and it does not pauses