swap image name ?

[eluser]Zeeshan Rasool[/eluser]
Is there any body who can help me??

I need to swap two files for example




if I need jim3 to become jim1 and jim1 to become jim3 do I need to first save one of them as a new file or is there some kind of swap command that will just swap the two?
anyway help is appreciated I am currently working on it to rename jim1 to swap and rename jim3 to jim1 and then swap to jim3. is there an easier way?

That is the only way to do it!

unless someone wrote a wrap function already.
I think re-naming is the best solution.

Well, you could write a function for it, but you would still need a temporary filename for the swap, it's just like swapping the values of two variables, you need a third temp variable.

[eluser]Zeeshan Rasool[/eluser]
you'r right guys!
i am now first copying a image and then after this delete the image in the last i m renaming both images.
So i have to use 3 functions

May be we can get it like this..

I don't understand why you need to copy anything?
Why can't you just rename the file.

slightly offtopic to someone above:
You don't need to use a third variable when swapping the values of two variables.

list($a, $b) = array($b, $a);

If you have 2 images and you want to swap their names, why not do this:
- get name of first image
- get name of second image
- rename first image to temp_image_swap_name (or whatever temp name you want to use)
- rename second image to old name of first image
- rename first image (that has temp name right now) to old name of second image

No need to create temporary images.

[eluser]Zeeshan Rasool[/eluser]
Thats nice ! but one thing that i am thinking is the draw back.
Actually im doing this process thru Ajax on more than 25 images So all images will be swapped their names on each event. But if there is any problem in internet or may be connection breaks due to some reason then this process will be stoped and all images can't be renamed

is the remaning should be done two at a time? i remember having something similar. so i let the js to do all the work and gave the user an update button to finish the job. if you are worried that the process may stop half way then use a task list approach and let a local cron do the renaming.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.