Creating a folder then dumping files into it!

This is a discussion on Creating a folder then dumping files into it! within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Hey I need to know a code that i can get to create a folder then dump a load of ...

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    27

    Creating a folder then dumping files into it!

    Hey

    I need to know a code that i can get to create a folder then dump a load of files out of a .zip or something into the folder.

    Is it possible?

  2. #2
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    system("md c:\whatever");//makes the directory
    system("mov c:\files\file.txt c:\whatever");//move to new directory

    www.easydos.com has a listing of all the commands...copy and stuff may be better as opposed to move.
    PHP and XML
    Let's talk about SAX

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    27
    I tried it but it doesn't work!

    I don't really need to know it just want to see if it can be done!

  4. #4
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    system("md c:\whatever");//makes the directory
    system("mov c:\files\file.txt c:\whatever");//move to new directory
    Use double \ instead.
    system("md c:\\whatever");

  5. #5
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    thanks for helping him out shaik, i spaced on that one.
    PHP and XML
    Let's talk about SAX

  6. #6
    Registered User
    Join Date
    Jul 2002
    Posts
    27
    Yeah i got that working.

  7. #7
    Registered User
    Join Date
    Jul 2002
    Posts
    27
    Code:
    #include <stdlib.h> 
    
    int main() 
    
    { 
    system("md c:\\test");//makes the directory 
    system("mov c:\test.txt c:\test");//move to new directory 
    system("PAUSE");
    return 0; 
    }
    That move never worked.

    I get this:
    'mov' is not recognized as an internal or external command, operable program or batch file.
    Press any key to continue.....

    I tried doubling the \\ on the mov thing but it says:

    cannot open output file Format.exe C:\Dev-C++\mingw32\bin\ld.exe
    Permission denied
    C:\Documents and Settings\Chris\Desktop\C++\Makefile.win
    [Build Error] [Create.exe] Error 1


    Any ideas?

  8. #8
    Registered User
    Join Date
    Jul 2002
    Posts
    27
    Ok thanks got that working.

    But what i really want is anyway i can get it to take the file out of a .zip file and into the folder?

  9. #9
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    dude, search for zip on the board, in the last month i know of at least 20 posts asking this same stupid question
    PHP and XML
    Let's talk about SAX

  10. #10
    Registered User
    Join Date
    Jul 2002
    Posts
    27
    Well sorry but i didn't know did i!

  11. #11
    PC Fixer-Upper Waldo2k2's Avatar
    Join Date
    May 2002
    Posts
    2,001
    just giving you advice, when you search you'll usually come up with something. Theres been god knowns how many threads on this site.
    PHP and XML
    Let's talk about SAX

  12. #12
    Registered User
    Join Date
    Jul 2002
    Posts
    27
    Thanks, i searched when you told me to didn't have much time to look at it. But i will have another look now.

  13. #13
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    To expand on Salem's advice for the zip file stuff, awhile ago I created 2 functions for zip file, with his code troubleshooting assistance. You may want to take a look at the following if it will help any:
    Code:
    #include "Install.h"
    
    void ZipCheck ( char * FileCheck, char * Name )
    {
    	FILE * Tmp;
    	if ( ( Tmp = fopen( FileCheck, "r" ) ) == 0 )
    	{
    		printf("%s not found, skipping.\n", Name);
    	}
    	else
    	{
    		/* Nothing */
    	}
    	fclose(Tmp);
    }
    
    void ZipExtract ( char * SourceFile, char * Destination, char * Name )
    {
    	char * args[6];
    	args[0] = " -qq "; /* makes unzip.exe quiet */
    	args[1] = " -C "; /* make unzip.exe noncase-sensative */
    	args[2] = SourceFile;
    	args[3] = " -d "; /* create new subdirectory for file(s) */
    	args[4] = Destination;
    	args[5] = NULL; /* more output supression to unzip.exe */
    	printf("Copying..");
    	spawnv( P_WAIT, "d:\\unzip.exe", args );
    
    	printf("\b\b\b\b\b\b\b\b\bCopied -  %s\n", Name);
    }
    For the code example at hand, I am using the unzip program found on this page for some of my C / C++ programs I code that help my emulation hobby along to move faster.

    A common way to use the functions:
    Code:
    #include <stdio.h>
    
    int main ( void )
    {
    	ZipCheck("d:\\directory\\foo.zip", "Foo.zip");
    	/* arg 1 = zip file, arg 2 = commercial name of zip file */
    	
    	ZipExtract("d:\\directory\\foo.zip", "c:\\NewDirectory", "Software name");
    	/* OR */
    	ZipExtract("d:\\directory\\foo.zip ReadMe.txt", "c:\\Newdirectory\\Docs", "ReadMe File");
    	
    	return 0;
    }
    If the zip program at question will not work for you, replace it with another. Manipulate the spawn function setup to work in conjunction with the new zip program.

    To even expand further:
    Code:
    #include <stdio.h>
    #include <process.h>
    
    int ZipCheck ( char * FileCheck, char * Name );
    int ZipExtract ( char * SourceFile, char * Destination, char * Name );
    
    int main ( void )
    {
    	if ( ZipCheck("c:\\windows\\readme.zip", "ReadMeZip") == 0 )
    	{
    		ZipExtract("c:\\windows\\readme.zip",
    		"c:\\windows\\desktop",
    		"ReadMe");
    	}
    	else
    	{
    		printf("Exiting on error");
    		return 1;
    	}	
    	return 0;
    }
    
    int ZipCheck ( char * FileCheck, char * Name )
    {
    	FILE * Tmp;
    	if ( ( Tmp = fopen( FileCheck, "r" ) ) == 0 )
    	{
    		printf("%s not found, skipping.\n", Name);
    		return 1;
    	}
    	else
    	{
    		fclose(Tmp);
    		return 0;
    	}
    }
    
    int ZipExtract ( char * SourceFile, char * Destination, char * Name )
    {
    	char * args[6];
    	args[0] = " -qq "; /* makes unzip.exe quiet */
    	args[1] = " -C "; /* make unzip.exe noncase-sensative */
    	args[2] = SourceFile;
    	args[3] = " -d "; /* create new subdirectory for file(s) */
    	args[4] = Destination;
    	args[5] = NULL; /* more output supression to unzip.exe */
    	printf("Copying..");
    	spawnv( P_WAIT, "c:\\windows\\command\\unzip.exe", args );
    
    	printf("\b\b\b\b\b\b\b\b\bCopied -  %s\n", Name);
    	return 0;
    }
    The above program should work so long as you satisfy it's conditions for working.
    The world is waiting. I must leave you now.

  14. #14
    Registered User
    Join Date
    Jul 2002
    Posts
    27
    Ok thanks, i'll try it sometime just i have been busy!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Number of files in a folder
    By gadu in forum C Programming
    Replies: 1
    Last Post: 10-09-2008, 06:16 PM
  2. Creating a Folder
    By Junior89 in forum C++ Programming
    Replies: 9
    Last Post: 11-06-2004, 11:45 PM
  3. writing files to a specified folder
    By jverkoey in forum Windows Programming
    Replies: 5
    Last Post: 03-29-2003, 10:09 PM
  4. ...how to get the number of files in a folder
    By toby1909 in forum Windows Programming
    Replies: 5
    Last Post: 02-01-2002, 04:43 PM
  5. creating make files
    By Unregistered in forum Linux Programming
    Replies: 4
    Last Post: 09-22-2001, 01:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21