Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Append name of parent folders to the names of the files  (Read 11507 times)

0 Members and 1 Guest are viewing this topic.

ghostdog74



    Specialist

    Thanked: 27
    Re: Append name of parent folders to the names of the files
    « Reply #15 on: March 14, 2009, 10:44:51 AM »
    i think the 2 of you should stop. Calling someone a jerk is unwarranted and rude. All you need to do is to ignore the post. the truth will come to light whether those solutions work or not.

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Append name of parent folders to the names of the files
    « Reply #16 on: March 14, 2009, 01:23:41 PM »
    All you need to do is to ignore the post.

    problem being of course that the OP might NOT ignore the post and risk data loss.

    Quote
    Append name of parent folders to the names of the files

    the only one that does this so far is Dias's batch file. Billrich's command output shows a single file, a manufacturered "jpeg" containing a line of text being manually renamed via the ren command. Which simply begs the question since the OP wants to do this automatically, not manually!

    (and, while I admire the courage of using various complementary and low contrast colours in the posts, it really adds no information other then "look at me, I can change text color!")

    I was trying to dereference Null Pointers before it was cool.

    Dias de verano

    • Guest
    Re: Append name of parent folders to the names of the files
    « Reply #17 on: March 14, 2009, 01:58:05 PM »
    BC_Programmer++

    billrich

    • Guest
    Re: Append name of parent folders to the names of the files
    « Reply #18 on: March 14, 2009, 02:17:22 PM »
     My remarks were rude and unnecessary.

    I apologize  to everyone.
    « Last Edit: March 15, 2009, 09:25:18 PM by billrich »

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Append name of parent folders to the names of the files
    « Reply #19 on: March 15, 2009, 09:19:53 AM »
    How do abusive posts by Dias de verano help Observer, the original poster?

    about the same amount as describing the "manual" method of renaming/copying. If that was their goal they could use Windows Explorer- so it stands to reason that they want a multitude of files to be processed.


    So far the only script that processes more then one file is Dias'. Your's, while explanatory about how to manually rename/copy a file, is almost certainly not the intended result.

    on the topic of colour changing- you can never be sure what background your color will be against; additionally your main usage appears to be for quoting, a more robust method for which is already integrated in the forum.


    In short the conclusion is clear- telling us we misunderstand and providing a solution that completely contradicts both the implied as well as the explicit requirements set forth by the original poster; additionally echoing arbitrary text to a image file is crazy- since it has no presupposed reasoning behind it. One could have just as easily used a text file, or other example file- but the result would have been just as pointless on account of your attempts describing manual methods of performing a file rename, which would kind of go against:

    Quote
    I would like to copy these files in

    Even after seeing this- you insist that your method is accurate, that they want to rename; and that we simply cannot read, and you cannot see how we do not understand. This in all fairness meets even the strictest definition of "jerk", to which I might add that he never said you "were" a jerk, but rather that you were being one- a slight difference.

    also, he never called you stupid:
    Quote
    echo abc.jpg >> Abc.jpg is just plain stupid, and if you can't see why,

    This has been explained. a jpg file, as I'm sure you are aware, is a image file. appending arbitrary text or echoing arbitrary text to a file with a jpg extension simply doesn't make sense- as you clarified later, this was to create "sample" files for your demonstration of the manual use of the rename command; why you decided that the example would best include echoing text to a fixed-format file and subsequently presenting that as part of your solution is beyond me, but the idea of doing so is stupid, not in the context of your usage as a demonstration but in the context that the OP might perform this same action on their files- causing almost certain file corruption.

    I was trying to dereference Null Pointers before it was cool.

    billrich

    • Guest
    Re: Append name of parent folders to the names of the files
    « Reply #20 on: March 15, 2009, 11:26:55 AM »
     My remarks were rude and unnecessary.

    I apologize  to everyone.
    « Last Edit: March 15, 2009, 09:26:04 PM by billrich »

    mroilfield



      Mentor
    • Thanked: 42
      • Yes
      • Yes
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 11
    Re: Append name of parent folders to the names of the files
    « Reply #21 on: March 15, 2009, 11:55:40 AM »
    I think some people need to just get over it and either help the OP or stop posting altogether.

    I think a can see a lock coming soon.
    You can't fix Stupid!!!

    harry 48



      Egghead

    • lay back , relax and chill out
    • Thanked: 129
      • Yes
      • Yes
      • Yes
      • Dribbling Pensioner
    • Certifications: List
    • Experience: Familiar
    • OS: Windows 7
    Re: Append name of parent folders to the names of the files
    « Reply #22 on: March 15, 2009, 12:45:42 PM »
    i agree mroilfield , the children fight to much , put the locks on them both

    Dias de verano

    • Guest
    Re: Append name of parent folders to the names of the files
    « Reply #23 on: March 15, 2009, 12:47:22 PM »
    I see the forum veterans are joining in.

    harry 48



      Egghead

    • lay back , relax and chill out
    • Thanked: 129
      • Yes
      • Yes
      • Yes
      • Dribbling Pensioner
    • Certifications: List
    • Experience: Familiar
    • OS: Windows 7
    Re: Append name of parent folders to the names of the files
    « Reply #24 on: March 15, 2009, 01:31:58 PM »
    sure we must as a forum is not limited to young people and children

    [attachment deleted by admin]

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Append name of parent folders to the names of the files
    « Reply #25 on: March 15, 2009, 01:54:50 PM »
    BC_Programmer,

    BC_Programmer does not work for the Computer Hope Board. BC_Programmer  is not in charge of anything.  I suspect BC_Programmer
    flunked out college because BC_Programmer spent all of his study time playing video games.  Now BC_Programmer is back home doing nothing.



    By the way, BC_Programmer pretends he is so well informed about Programming but none of his posts show any code. All  BC_Programmer
    does is play off other people's code

    BC_Programmer is a phony.



     
     
     


    ::)


    very well then...


    Code: [Select]
    interesting... exceeded the maximum post length...


    I attached it instead.

    You would think I would be concerned about theft of my code, but the class is useless without the rest my other classes, modules, and even resources, I believe.


    Shall I also post my XML parsing code to generate VBAccelerator Commandbar heirarchies? Or perhaps my COM code for showing the right-click explorer menu? Or perhaps some other even more down-level COM code using weak references and Copymemory into VB object references, delicately handled with carefully crafted coe to prevent VB from accessing a object reference it believes to contain a valid object but in fact has been filled with zeros because of using copymemory directly into the pointer retrieved by the undocumented ObjPtr() function.

    Or perhaps my new version of my code for enumerating alternate data streams using NTQueryInformationFile()?


    Actually, that's short enough to post here:

    Code: [Select]
    Public Function ListStreams(sPath As String) As CAlternateStreams
        Dim IOS As IO_STATUS_BLOCK
        Dim BBuf() As Byte
        Dim FSInfo As FILE_STREAM_INFORMATION
        Dim LBuf As Long, LInfo As Long, LRet As Long
        Dim LErr As Long
        Dim sName As String, SNames As String
        
        Dim newstreams As CAlternateStreams
        Set newstreams = New CAlternateStreams
        
        newstreams.Owner = sPath
        On Error Resume Next
        'ListStreams = ""
        LRet = CreateFile(sPath, DesiredAccessFlags.STANDARD_RIGHTS_READ, FILE_SHARE_READ, 0&, OPEN_EXISTING, _
        FILE_FLAG_BACKUP_SEMANTICS, 0&)
        If (LRet = -1) Then Exit Function
        
        LBuf = 4096
        LErr = 234
        ReDim BBuf(1 To LBuf)
        
        Do While LErr = 234
        
            LErr = NtQueryInformationFile(LRet, IOS, ByVal VarPtr(BBuf(1)), LBuf, _
            ByVal FileStreamInformation)
            If (LErr = 234) Then
            LBuf = LBuf + 4096
            ReDim BBuf(1 To LBuf)
            End If
            
        Loop
        
        LInfo = VarPtr(BBuf(1))
        Dim newstream As CAlternateStream
        Do
        
            CopyMemory ByVal VarPtr(FSInfo.NextEntryOffset), ByVal LInfo, Len(FSInfo)
            'CopyMemory ByVal VarPtr(FSInfo.StreamName(0)), ByVal LInfo + 24, _
    '
            'FSInfo.StreamNameLength
            sName = Left$(FSInfo.StreamName, FSInfo.StreamNameLength / 2)
            
            If (InStr(1, sName, DATA_1, 1) = 0) And (InStr(1, sName, DATA_2, 1) = 0) _
            And (sName <> "") Then
                'SNames = SNames & Mid$(sName, 2, Len(sName) - 7) & " * " & _
                CStr(FSInfo.StreamSize) & "|"
              
                Set newstream = New CAlternateStream
                newstream.Init sPath, Mid$(sName, 2, Len(sName) - 7), _
                FSInfo.StreamSize, FSInfo.StreamSizeHi
                newstreams.Add newstream
                
            End If
            
            If FSInfo.NextEntryOffset Then
                LInfo = LInfo + FSInfo.NextEntryOffset
            Else
                Exit Do
            End If
            
        Loop
        CloseHandle LRet
        If (Len(SNames) > 0) Then SNames = Left$(SNames, (Len(SNames) - 1))
        Set ListStreams = newstreams
        'Stop
    End Function


    In order to be functional it would need some changes to exclude the usage of my CAlternateStream(s) classes; perhaps instead returning an array of User-defined types.


    BC_Programmer,
    BC_Programmer does not work for the Computer Hope Board. BC_Programmer  is not in charge of anything.  I suspect BC_Programmer
    flunked out college because BC_Programmer spent all of his study time playing video games.  Now BC_Programmer is back home doing nothing.


    Actually, I never went to college. From what I can tell it merely gives graduates a completely unjustified "holier then thou" attitude; of which I imagine you to be a prime example.

    Regardless, no academic institution that I know of teaches proper programming principles, instead they opt to teach the poor souls Object oriented programming, resulting in "object happy" programs from programmer's straight out of college, where a simple hello-world application becomes a derived class implementing ten different interfaces from "IHelloWorldPrintableText" to "IPrintableTextIsString" and using variable naming conventions that follow hungarian notation so closely as to make anybody sick. The problem with such code is not that it doesn't work, or the fact that it is slower then a dead dinosaur, but rather that nobody can see the code through the objects.

    Take as an example, Bruce McKinney; while his Hardcore Visual Basic book has a few loose ends and various questionable assumptions, it is essentially a bible that VB Classic Programmers, which includes quite a rank, such as Karl E. Peterson, and Steve Mcmahon... both of which have quite obviously gone quite past Bruce's original definition of a "hardcore VB programmer". The point? Well- looking at Bruce McKinney's Credentials, we find that his post-secondary Education in Computer Science is Nil. Non-existent. (well, in all fairness he describes it as "the school of hard knocks").

    The conclusion one can draw upon this, and various other examples, not to mention people who it can almost be presupposed don't have a brain that you later discover have a master's degree (and no, I am not talking about you billrich; I know several... folks that are working in areas that while proper for their "education" does not fit their "intelligence".).

    Only practical Experience and hands-on knowledge provide a positive benefit. For a large sum a university or college can show you how to teach yourself, but you can do the same for free at home, with the proper literature, such as "Code Complete".

    learning in college what a Binary Tree is is useless. I was never formally taught what a binary tree was at any point in my education- I taught myself- mostly from a java data structures book, actually, but I digress. Even without such education I can still code up a quick, if not completely generic and therefore useless in most contexts, tree class that supports all the proper traversals of the tree being returned in an array, including Pre-Order, In-Order and Post-Order traversals.

    And of course Red-Black trees and Binary Sorted trees, AVL trees and the like, none of which I want to get into here anyway.

    The thing is-

    none of it matters.

    You can learn about the specifics of AVL trees all you want, but unless you're smart enough, you'll never make the connection later on in the field when a problem is presented, "Golly, I could Use Red-Black trees here". And in fact- with the proper "smarts" /analytic thinking even the most "unlearned" folk can still make the connection as to appropriate tool, even if they don't know the proper term for that tool.


    [attachment deleted by admin]
    « Last Edit: March 15, 2009, 02:53:35 PM by BC_Programmer »
    I was trying to dereference Null Pointers before it was cool.

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Append name of parent folders to the names of the files
    « Reply #26 on: March 15, 2009, 01:56:52 PM »
    ... In summary- Computer Science and Computer programming are two widely differing fields, just like Applied mathematics is different from differential calculus.
    I was trying to dereference Null Pointers before it was cool.

    harry 48



      Egghead

    • lay back , relax and chill out
    • Thanked: 129
      • Yes
      • Yes
      • Yes
      • Dribbling Pensioner
    • Certifications: List
    • Experience: Familiar
    • OS: Windows 7
    Re: Append name of parent folders to the names of the files
    « Reply #27 on: March 15, 2009, 02:03:48 PM »
    good on you bcp your not a guru for nothing

    billrich

    • Guest
    Re: Append name of parent folders to the names of the files
    « Reply #28 on: March 15, 2009, 09:17:34 PM »
    To:  Dias de verano

    C:\>type renjpg.bat
    @echo off

    copy *.jpg  c:\new\

    cd c:\new

    for /F   %%i in ('dir /B *.jpg') do ren %%i 2009.January.%%i

    C:\>

    C:\new>dir *.jpg
      Volume Serial Number is B8F2-4B99

     Directory of C:\new

    03/05/2008  12:26 PM           221,632 2009.January.Art0002.JPG
    08/04/2004  07:00 AM            66,287 2009.January.Autumn.jpg
    08/04/2004  07:00 AM            61,365 2009.January.Azul.jpg
    12/17/2008  11:02 PM           103,211 2009.January.BabyDeer.jpg
    11/29/2007  02:38 PM           205,464 2009.January.bow.jpg
    11/29/2007  07:57 PM           164,462 2009.January.bow3.jpg
    02/06/2008  09:03 PM            42,339 2009.January.CatandMouse.jpg
    01/11/2008  01:08 PM            61,917 2009.January.Farmhouse.jpg
    08/04/2004  07:00 AM            50,511 2009.January.Follow.jpg
    12/05/2007  04:20 PM            66,302 2009.January.Friend.jpg
    06/03/2008  09:18 PM           101,976 2009.January.getoutcar.jpg
    08/04/2004  07:00 AM            42,728 2009.January.Home.jpg
    10/21/2008  02:58 PM            45,483 2009.January.JJB.jpg
    10/21/2008  02:59 PM            70,833 2009.January.John_Jean.jpg
    11/30/2008  06:38 PM            37,469 2009.January.Joy0001.jpg
    01/26/2009  12:23 PM            17,629 2009.January.mam.jpg
    11/17/2007  02:45 PM            46,994 2009.January.nap1117.jpg
    02/28/2008  07:12 PM           126,734 2009.January.parrot.jpg
    09/24/2008  09:07 PM            22,033 2009.January.piper.jpg
    08/04/2004  07:00 AM            44,190 2009.January.Radiance.jpg
    12/03/2008  07:07 PM            58,551 2009.January.redflower.jpg
    05/08/2008  07:47 PM            63,784 2009.January.Slide2.jpg
    05/08/2008  07:48 PM            41,097 2009.January.Slide4.jpg
    05/09/2008  07:10 AM            42,105 2009.January.Slide6.jpg
    05/09/2008  07:11 AM            51,122 2009.January.Slide8.jpg
    05/09/2008  07:12 AM            55,696 2009.January.Slide9.jpg
    08/04/2004  07:00 AM            73,159 2009.January.Tulips.jpg
    08/04/2004  07:00 AM            37,246 2009.January.Wind.jpg
    08/22/2008  10:17 AM             8,165 2009.January.wolf3.jpg
                  29 File(s)      2,030,484 bytes
                   
    C:\new>

    Dias de verano

    • Guest
    Re: Append name of parent folders to the names of the files
    « Reply #29 on: March 16, 2009, 01:11:51 AM »
    If the original filename had any spaces in it it would fail.